>>I prefer a lot this syntax:
>>
If oTest Is Nothing Then
>> MsgBox ("nothing")
>>Else
>> MsgBox ("object")
>>End If
>
>Hi Eric,
>
>Me too, but I need the opposite. I have a private var in a class module that holds an object reference to an AutoCad object. A method will create the object. When the the class terminates, it may or may not have the object (The method to create it may have never been called). If it has the object, I need to call one of it's methods to delete it.
>
>
Private MarkObject As AcadCircle
>
>Private Sub Class_Terminate()
> ' If the MarkObject is still here delete it.
> If Not MarkObject Is AcadCircle Then
> MarkObject.Delete
> Set MarkObject = Nothing
> End If
>End Sub
>
>Is there a better way of doing it?
I see one problem with it, if MarkObject is
not an object of the AcadCircle, it will not be able to find the Delete method! Maybe you just forget to delete the
Not?
Private Sub Class_Terminate()
' If the MarkObject is still here delete it.
If MarkObject Is AcadCircle Then
MarkObject.Delete
Set MarkObject = Nothing
End If
End Sub
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com