5.2.4.1.2 Default Instance Variables Static Semantics

  • A class module has a default instance variable if its VB_PredeclaredId attribute or

  • VB_GlobalNamespace attribute has the value "True". This default instance variable is created with module extent as if declared in a <module-variable-declaration> containing an <as-autoobject> element whose <class-type-name> was the name of the class.

  • If this class module’s VB_PredeclaredId attribute has the value "True", this default instance variable is given the name of the class as its name. It is invalid for this named variable to be the target of a Set assignment. Otherwise, if this class module’s VB_PredeclaredId attribute does not have the value "True", this default instance variable has no publicly expressible name.

  • If this class module’s VB_GlobalNamespace attribute has the value "True", the class module is considered a global class module, allowing simple name access to its default instance’s members as specified in section 5.6.10.

  • Note that if the VB_PredeclaredId and VB_GlobalNamespace attributes both have the value "True", the same default instance variable is shared by the semantics of both attributes.