Home All Groups Group Topic Archive Search About

How to pass an object between forms.

Author
22 Mar 2006 3:09 PM
Matt
I'm using VB.Net 2005

Ok so I have this object that I create on Form 1.
Form 1 in turn calls Form 2 that needs a copy of that object to do its
work.

Is there any easy way that I can copy or pass that Form 1 object to
Form 2?  I don't want to make it a global object.

Author
22 Mar 2006 3:57 PM
Julia Beresford
Yeah, create a public property on Form2 As your object type:

Form2 code:

Public x As myObjectType

...and when the instance of From2 is created in Form1 set the property to be
the instance of the object in Form1:

Form1 code:

dim frm as New Form2
frm.x = myobject

Julia.