single form instance

G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top