title: How can a VBA object instance tell if it is the default instance?
body: <p>This doesn't work:</p>
  
  <hr>
  
  <pre><code>clsTestDefaultInstance
  
  Dim HowAmIInitialised As Integer
  
  Private Sub Class_Initialize()
  HowAmIInitialised = 99
  End Sub
  </code></pre>
  
  <p></p>
  
  <pre><code>Public Sub CallMe()
    Debug.Print "HowAmIInitialised=" &amp; HowAmIInitialised
  End Sub
  </code></pre>
  
  <hr>
  
  <p>i.e <code>clsTestDefaultInstance.CallMe()</code> outputs <code>HowAmIInitialised=99</code> because  <code>Class_Initialize()</code> is called even for the default instance.</p>
  
  <pre><code>VERSION 1.0 CLASS
  BEGIN
    MultiUse = -1  'True
  END
  Attribute VB_Name = "clsTestDefaultInstance"
  Attribute VB_GlobalNameSpace = False
  Attribute VB_Creatable = False
  Attribute VB_PredeclaredId = True
  Attribute VB_Exposed = False
  Option Compare Database
  Option Explicit
  
  ' test how class instance can tell if it is default
  'clsTestDefaultInstance
  
  Dim HowAmIInitialised As Integer
  
  Private Sub Class_Initialize()
    HowAmIInitialised = HowAmIInitialised + 1
  End Sub
  
  Public Sub CallMe()
    Debug.Print "HowAmIInitialised=" &amp; HowAmIInitialised
  End Sub
  </code></pre>