G
Guest
I want to declare a local copy of an object so I can modify the local
version without affecting the original copy. But when I update my local copy,
the original object changes, too.
My original object is a collection I’ve defined. I started with a class
definition:
Public Class MyClassDef
Inherits System.Collections.CollectionBase
…
End Class
Then I declared an instance of my collection:
Public MyMasterObject As New MyClassDef
I try to make a local copy of this collection to use only on one form. I
have declared a module level private variable like this:
Public Class MyForm
Inherits System.Windows.Forms.Form
Private MyLocalObject As New MyClassDef
Private Sub MySub1
MyLocalObject = MyMasterObject
End Sub
Private Sub MySub2
MyLocalObject.Item(0).Value = <new value>
End Sub
End Class
When I execute MySub2, my intention is to modify MyLocalObject without
affecting MyMasterObject. However, MyMasterObject is updated, too.
Please point me to a description of declaration/scope/referencing
information that will help me figure out how to separate my local copy from
my original object.
TIA,
JZ
version without affecting the original copy. But when I update my local copy,
the original object changes, too.
My original object is a collection I’ve defined. I started with a class
definition:
Public Class MyClassDef
Inherits System.Collections.CollectionBase
…
End Class
Then I declared an instance of my collection:
Public MyMasterObject As New MyClassDef
I try to make a local copy of this collection to use only on one form. I
have declared a module level private variable like this:
Public Class MyForm
Inherits System.Windows.Forms.Form
Private MyLocalObject As New MyClassDef
Private Sub MySub1
MyLocalObject = MyMasterObject
End Sub
Private Sub MySub2
MyLocalObject.Item(0).Value = <new value>
End Sub
End Class
When I execute MySub2, my intention is to modify MyLocalObject without
affecting MyMasterObject. However, MyMasterObject is updated, too.
Please point me to a description of declaration/scope/referencing
information that will help me figure out how to separate my local copy from
my original object.
TIA,
JZ