You'll need a reference to whatever form you want to access. If you need form1 to create form2 and form2 should access properties on form1 then you might try passing form1 in the constructor. Here is some code that demonstates this.
Public Class Form2
Private _parent As Form1
'Accepts Form1
Public Sub New(ByVal parent As Form1)
InitializeComponent()
'Sets parent
_parent = parent
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Displays the text of the parent
MsgBox(_parent.Text)
End Sub
End Class
This is what form1's code might look like.
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Create instance of form2 and pass a reference to this form
Dim frm As New Form2(Me)
frm.Show()
End Sub
End Class
Enter your message below
Sign in or Join us (it's free).