How to pass an object between forms.

M

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.
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top