You need access to the instance of your form in order to access it. This is easily accomplished by declaring your variable globally in your class. Something like this
Public Class Form1
Private frmGetInfo As Form2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If frmGetInfo Is Nothing OrElse frmGetInfo.IsDisposed Then
' An instance of the form hasn't been created yet or has been closed
' so create a new instance
frmGetInfo = New Form2
frmGetInfo.MdiParent = Me
End If
' Show the form
frmGetInfo.Show()
End Sub
End Class
Now because you have declared the variable globally you can access the instance from SaveMenu. However, I don't recommend accessing controls on the GetInfo form. Instead you should create properties on this form that expose the values. This is good programming practice because this way the underlying controls can change, but to your other classes the properties will look the same. It may not seem like a big deal here, but it's best to get yourself used to good habits.
An alternative approach might be to create a class that represents the information your gathering. Your GetInfo form could accept this class in a constructor. The parent form would pass an instance of this Data class to the GetInfo form which then could update the values when the user enters them. Your SaveMenu would then only need access to your Data class instance instead of knowing about the GetInfo form.
Also, should your GetInfo form really be a child form. It sounds to me like it's a dialog, but then again I don't know much about the overall application so I don't really know.
Enter your message below
Sign in or Join us (it's free).