天天看点

Vb.net窗口调用问题

源代码:

   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

继续阅读