Posted By

DaveChild on 09/11/08


Tagged

class Singleton


Versions (?)


Advertising

Submit Site


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

Expand | Embed | Plain Text
  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.

Download royalty free graphics