Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IsNothing Function since I frequently forget it is not part of VB IsSomething functions

What VB shoud be able to do!

IsNothing Function since I frequently forget it is not part of VB IsSomething functions

by  SBendBuckeye  Posted    (Edited  )
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
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top