Suppose you have Button1 on Form1. If the user clicks Button1, I want
to show Form2 modelessly. If Form2 is already open I just want to
redisplay it, not open a new window. Thru trial and error I came up
with the following code. Is there a better way to do this?
Public Class Form1
Dim objForm As Form2
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
If (IsNothing(objF orm)) Then
objForm = New Form2
objForm.Show()
Else
If (objForm.Create d) Then
objForm.BringTo Front()
Else
objForm = New Form2
objForm.Show()
End If
End If
End Sub
End Class
Comment