single form instance

  • Thread starter Thread starter Maileen
  • Start date Start date
Hi Maileen

I hope you mean single form instance, and not single application instance...

Code for Form1 class:

1. Modify the public constructor so it is private
2. Add a shared member of type Form1
3. Add a public shared function that returns Form1

To get the form call:
Dim f As Form1 = Form1.GetForm()

HTH

Nigel Armstrong

Private Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
Private Shared mForm1 As Form1 = Nothing
Public Shared Function GetForm() As Form1
If mForm1 Is Nothing Then
mForm1 = New Form1
End If
Return mForm1
End Function
 
Back
Top