Is Operator
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

Is Operator

Compares two object reference variables.

result = object1 Is object2


Required. Any Boolean value.
Required. Any Object name.
Required. Any Object name.


The Is operator determines if two object references refer to the same object. However, it does not perform value comparisons. If object1 and object2 both refer to the same object, result is True; if they do not, result is False.


This example uses the Is operator to compare two object references. The object variable names are generic and used for illustration purposes only. The result is a Boolean value representing whether the two objects are identical.

Dim myObject As New Object
Dim otherObject As New Object
Dim yourObject, thisObject, thatObject As Object
Dim myCheck As Boolean
yourObject = myObject
thisObject = myObject
thatObject = otherObject
myCheck = yourObject Is thisObject   ' Returns True.
myCheck = thatObject Is thisObject   ' Returns False.
myCheck = myObject Is thatObject ' Returns False, if myObject is not thatObject.

See Also

Comparison Operators | Operator Precedence in Visual Basic | Operators Listed by Functionality | Operators

© 2015 Microsoft