源代碼:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim frm2 As New Form2
frm2.Show()
End Sub
這樣每次點選按鈕都會産生新的form2視窗
修改後
dim f2 as new Form2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If f2 Is Nothing Or f2.IsDisposed Then
f2 = New Form2
End If
f2.Show()
End Sub