Okay what if the user clicks the button in form1 and creates an instance of form2.
Now frm2 is not equal to nothing.
He changes his mind and cancels form2.
frm2 is not nothing anymore. so the code above will no longer open form2.
How do you make frm2 equal nothing again. Where would you set it equal to nothing so that the button on form1 can open it again?
Wing
Main Topics
Browse All Topics





by: DespPosted on 2003-07-04 at 05:24:16ID: 8856065
you need to create a Form2 instance in Form1 and access that ,,, if that doestn exist create that ... if that exist set focus to that instance
Dim frm2 As Form2 = Nothing ' Declare that in form1 global variable
'button1 on form1 clicks
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If frm2 Is Nothing Then
frm2 = New Form2()
frm2.MdiParent = Me.MdiParent
frm2.Show()
Else
frm2.Focus()
End If
End Sub