Public Class Form1
Public Sub Button1Click(ByVal sender as Object, ByVal e As EventArgs) Handles Button1.Click
'Passes the value of TextBox txtTextBoxID to the constructor of Form2
Dim frmNewForm as New Form2(txtTextBoxID.Text.Trim)
frmNewForm.Show()
End Sub
End Class
Public Class Form2
Dim TextIDFromForm1 As String = ""
Public Sub New(ByVal PassTextID As String)
InitializeComponents()
'The value passed from Form1 to this constructor is
' temporarily in PassTextID. So we transfer the value to
' a variable on Form2 to hold it for the duration of this
' instance of Form2
TextIDFromForm1 = PassTextID
End Sub
End Class