Proper syntax for testing if an Object has been Set?

M

Maury Markowitz

I'm trying to create a singleton of an COM object. This shouldn't be
difficult...

Private appxhandle As Object
Public Function appx() As Object
If IsNull(appxhandle) Then
Set appxhandle = CreateObject("MyApp", "myMachine")
End If
appx = apphandle
End Function

The inner part of the IF statement never gets called -- the variable is
never null. It does not work if I use IsMissing either, nor appxhandle =
Nothing (illegal for some reason) or IsObject etc.

Anyone know the magic incantation?

Maury
 
G

George Nicholson

If appxhandle Is Nothing Then
or, the converse
If Not appxhandle Is Nothing Then

HTH,
 
Top