In the form with the control you want to reference:
Public Property CustomerNo() As TextBox
Get
Return txtCustomerNo
End Get
Set(ByVal Value As TextBox)
txtCustomerNo = Value
End Set
End Property
In the form you wish to reference the control:
Dim CustomerNo as string = _sourceForm.CustomerNo.Text
It's a bad design to do this, but it's the simplest method - and should set you on your way.
If you are only interesting in the value entered in the text box then the following might be better:
Public ReadOnly Property CustomerNo() As String
Get
Return txtCustomerNo.Text
End Get
End Property
The above will require the second form to have a reference to the actual instance of the first form. Add the below to the second form:
Private _sourceForm as frmGenerate
Public Property SourceForm() As frmGenerate
Get
Return _sourceForm
End Get
Set(ByVal Value As frmGenerate)
_sourceForm = Value
End Set
End Property
Now you can do the following where you handle the creation and startup of your second form:
Dim customersForm as new frmCustomers
customersForm.SourceForm = Me
customersForm.Show()
EDIT:
I have constructed a sample project for you here:
http://www.yourfilelink.com/get.php?fid=595015
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…