The VBA IsObject function returns a Boolean, indicating whether a supplied variable represents an Object variable type.
The syntax of the function is:
Where the supplied Expression is the variable name that you want to test.
The following example uses the VBA IsNumeric function to test four variables.
' Test if variables var1 and var2 represent Object variable types.
Dim var1 As Object
Dim var2, var3, var4 Dim isObj1 As Boolean Dim isObj2 As Boolean Dim isObj3 As Boolean Dim isObj4 As Boolean
isObj1 = IsObject( var1 )
' The variable isObj1 is now equal to True.
isObj2 = IsObject( var2 )
' The variable isObj2 is now equal to False.
Set var3 = Range( "A1" )
Set var4 = Range( "A1" )isObj3 = IsObject( var3 ) ' The variable isObj3 is now equal to True. Set var4 = Nothing isObj4 = IsObject( var4 ) ' The variable isObj4 is now equal to True. |
The above examples show that the isObject function returns: