Search This Blog

Tuesday, February 24, 2009

Cloning objects in VB6

Add method to object:

Public Function Clone() As Home
Dim m As New MemoryStream()
Dim b As New BinaryFormatter()
b.Serialize(m, Me)
m.Position = 0
Return b.Deserialize(m)
End Function

Showing code
Dim obj As New MyObject()
Dim objNew As MyObject= obj .Clone





No comments: