Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VBA check if object is set

Tags:

vba

ms-access

I have a global variable that is an instance of my custom class.

How do I check if the object is set or if I need to initialize it?

like image 875
Icode4food Avatar asked Apr 13 '10 17:04

Icode4food


1 Answers

If obj Is Nothing Then     ' need to initialize obj: '     Set obj = ... Else     ' obj already set / initialized. ' End If 

Or, if you prefer it the other way around:

If Not obj Is Nothing Then     ' obj already set / initialized. ' Else     ' need to initialize obj: '     Set obj = ... End If 
like image 153
stakx - no longer contributing Avatar answered Oct 10 '22 10:10

stakx - no longer contributing