ReDim Preserve varname (dimensions)
'A variable to hold the reference to the main form.
Private mainForm As (class of main form)
'The constructor is altered to accept the reference to the main form as the subform is created. Make sure this variable is passed ByRef. ByVal will create another copy, leading again to your original problem.
Public Sub New(ByRef MainFormReference As (class of main form))
.
(whatever VB.NET already put in here, don't mess with it)
.
mainForm = MainFormReference
End Sub
'Creating a new instance of the subform with a reference to the main form, "Me".
Dim subform As New (class of subform)(Me)
'Brings up the main form.
mainForm.Show()
'Passes data to the main form.
mainForm.FictionalVariable = whatever
'Changes the text of a text box on the main form.
mainForm.TextBoxName.Text = "whatever"
Users browsing this forum: No registered users and 172 guests