, , . ; , .
VB.NET VB 2005, . , VB6, VB6 , . , , , , - . , , .
, VB.NET, . , . , , , .
, . , , , , , , , .
, :
http://jmcilhinney.blogspot.com.au/2009/07/vbnet-default-form-instances.html
http://jmcilhinney.blogspot.com.au/2012/04/managing-data-among-multiple-forms-part.html
, .
, singleton:
Public Class Form1
''' <summary>
''' The one and only instance.
''' </summary>
Private Shared _instance As Form1
''' <summary>
''' Gets the one and only instance.
''' </summary>
Public Shared ReadOnly Property Instance As Form1
Get
'If there is no instance or it has been destroyed...
If _instance Is Nothing OrElse _instance.IsDisposed Then
'...create a new one.
_instance = New Form1
End If
Return _instance
End Get
End Property
'The only constructor is private so an instance cannot be created externally.
Private Sub New()
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
End Sub
End Class
Form1 , .
Form1.Instance.Show()
Form1.Instance.Activate()
, .