Example of Singleton Design pattern

The main key feature of singleton pattern is that only one single instance will created of the given object.

EXAMPLE

Public Class SingletonCode

 

    'shared members

    Private Shared _instance As New SingletonCode

 

    Public Shared Function Instance() As SingletonCode

        Return _instance

    End Function

 

    'instance members

    Private Sub New()

        'public instantiation disallowed

    End Sub

 

    'other instance members

    '...

 

End Class