We Recommend

Beginning VB.NET Beginning VB.NET
Visual Basic .NET is the latest version of the most widely used programming language in the world, popular with professional developers and complete beginners alike. This book will teach you Visual Basic .NET from first principles. You'll quickly and easily learn how to write Visual Basic .NET code and create attractive windows and forms for the users of your applications.


Posted By

DaveChild on 09/11/08


Tagged

class Singleton


Versions (?)


Who likes this?

2 people have marked this snippet as a favorite

Scooter
chavcho


VB.NET Singleton Class


Published in: VB.NET 


URL: http://www.ondotnet.com/pub/a/dotnet/2002/11/11/singleton.html

  1. Public Class ClassName
  2.  
  3. Private Shared objClassName As ClassName
  4. Private Shared blnClassAlreadyCreated As Boolean = False
  5.  
  6. Private Sub New()
  7. End Sub
  8.  
  9. Public Shared Function setupClass() As ClassName
  10. If blnClassAlreadyCreated = False Then
  11. objClassName = New ClassName()
  12. blnClassAlreadyCreated = True
  13. End If
  14. Return objClassName
  15. End Function
  16.  
  17. End Class

Report this snippet 

Comments

RSS Icon Subscribe to comments
Posted By: DaveChild on September 12, 2008

To create a new instance of this object:

Public ClassNameInstance As ClassName = ClassName.setupClass()

You need to login to post a comment.