Refering to properties of one form from another

bjwade62

Well-known member
Joined
May 25, 2006
Messages
50
Programming Experience
3-5
I have two forms, FormA ancd FormB. On FormA I have a button that displays FormB. I have a sub in FormB that refers the path of a dirlistbox on FormA. The problem is that the sub in FormB is getting the wrong path of the dirlistbox on FormA.

Hope I explained this clearly and thanks for the help,

Bernie
 
The easiest answer is to pass a reference to FormA to FormB

FormB then has access to all of FormA's methods and properties via the reference.

Try this in Form B:

VB.NET:
private _CallerForm as Form
 
WriteOnly Property CallerForm as Form
Set(Vaue as Form)
_CallerForm =value
End Set
End Property

and when you open FormB pass the reference

VB.NET:
dim frm as new FormB
frm.CallerForm = Me
frm.show

you can then access any property or method using the _CallerForm object
 
Last edited:
Back
Top