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

Is Operator

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

Used to compare two object reference variables. Syntaxresult=object1Isobject2 The Is operator syntax has these parts:

PartDescription
resultRequired; any numeric variable.
object1Required; any object name.
object2Required; any object name.

Remarks If object1 and object2 both refer to the same object, result is True; if they do not, result is False. Two variables can be made to refer to the same object in several ways. In the following example, A has been set to refer to the same object as B:

Set A = B

The following example makes A and B refer to the same object as C:

Set A = C
Set B = C

Example

This example uses the Is operator to compare two object references. The object variable names are generic and used for illustration purposes only.

Dim MyObject, YourObject, ThisObject, OtherObject, ThatObject, MyCheck
Set YourObject = MyObject    ' Assign object references.
Set ThisObject = MyObject
Set ThatObject = OtherObject
MyCheck = YourObject Is ThisObject    ' Returns True.
MyCheck = ThatObject Is ThisObject    ' Returns False.
' Assume MyObject <> OtherObject
MyCheck = MyObject Is ThatObject    ' Returns False.
© 2018 Microsoft