'确保只调用一次这个Form1
Private Shared frmThisform As Form1
Public Shared Property OnlyOneInstance() As Form1
Get
If frmThisform Is Nothing OrElse frmThisform.IsDisposed Then
frmThisform = New Form1
End If
OnlyOneInstance = Form1
End Get
Set(ByVal Value As Form1)
frmThisform = Value
End Set
End Property
显示Form1调用时的代码:
With Form1.OnlyOneInstance
.MdiParent = Me
.Show()
.WindowState = FormWindowState.Maximized
End With
或者是:
Module Module1
Sub Main()
Application.Run(Form1.OnlyOneInstance)
End Sub
End Module