Table of contents
Collapse the table of content
Expand the table of content

IsObject Function

office 365 dev account|Last Updated: 6/12/2017
1 Contributor

Returns a Boolean value indicating whether anidentifier represents an objectvariable. SyntaxIsObject(identifier) The required identifierargument is a variable name. RemarksIsObject is useful only in determining whether aVariant is of VarTypevbObject. This could occur if the Variant actually references (or once referenced) an object, or if it contains Nothing.IsObject returns True if identifier is a variable declared withObject type or any validclass type, or if identifier is a Variant of VarTypevbObject, or a user-defined object; otherwise, it returns False. IsObject returns True even if the variable has been set to Nothing. Use error trapping to be sure that an object reference is valid.


This example uses the IsObject function to determine if an identifier represents an object variable. MyObject and and YourObject are object variables of the same type. They are generic names used for illustration purposes only.

Dim MyInt As Integer              ' Declare variables.
Dim YourObject, MyCheck           ' Note: default variable type is Variant
Dim MyObject As Object
Set YourObject = MyObject         ' Assign an object reference.
MyCheck = IsObject(YourObject)    ' Returns True.
MyCheck = IsObject(MyInt)         ' Returns False.
MyCheck = IsObject(Nothing)       ' Returns True.
MyCheck = IsObject(Empty)         ' Returns False.
MyCheck = IsObject(Null)          ' Returns False.
© 2017 Microsoft