VBA provides a long list of IsSomething functions for use in testing various properties or settings in your code. I
periodically forget that I have to test for VariableName Is Nothing since VBA does not provide an IsNothing function for my use. This usually happens at the end of a long day and can be quite frustrating so I wrote my own as below:
'**********************************************************
'* Function: Returns true if argument evaluates to nothing
'* 1. IsNothing(Nothing) -> True
'* 2. IsNothing(NonObjectVariableOrLiteral) -> False
'* 3. IsNothing(ObjectVariable) -> True if instantiated,
'* otherwise False
'**********************************************************
Public Function IsNothing(pvarToTest As Variant) As Boolean
On Error Resume Next
IsNothing = (pvarToTest Is Nothing)
Err.Clear
On Error GoTo 0
End Function 'IsNothing
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.