tags:

views:

223

answers:

1

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

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

Thanks, Jeff

+6  A: 
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
stakx
I knew it had to be simple when I Googled it and found nothing! Thanks for your help!
Icode4food
Finding Nothing was the correct answer! ;)
David-W-Fenton