I frequently forget that for objects you must check (Object is Nothing) since there is no intrinsic function IsNothing. Forgetting something like this is especially true in the middle of the night.
So I decided to write my own as below. The reason I use error checking is because IsNothing(Nothing) must return true which it would not normally since Nothing is not an object.
'*********************************************************
'* Function: IsNothing
'* Arguments: Variant
'* Returns: True if argument is Nothing, otherwise False
'* Example: IsNothing(YourObject)
'*********************************************************
Public Function IsNothing(pvar As Variant)
On Error Resume Next 'Handle errors here
IsNothing = (pvar Is Nothing)
On Error GoTo 0 'Reset error handling
End Function
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.