Pass the original instance of Form1
to the constructor of Form2
, like this:
Public Class Form2 Inherits Form
Dim theForm1 As Form1
Public Sub New(form1 As Form1)
theForm1 = form1
End Sub
Private Sub btnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOk.Click
' Call instance of Form1 passed in to change the values here
theForm1.ChangeValues()
End Sub
End Class
Now in Form1
, when you create the Form2
instance you need to pass the instance of Form1
, like this:
Dim frmForm2 As New Form2(Me)
frmForm2.ShowDialog()
Note:
Me
is a reference to the current class,Form1
in this case.