Printer Friendly Version      Send     
Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio .NET
Reference
Operators
 Is Operator
This page is specific to
Microsoft Visual Studio 2003/.NET Framework 1.1

Other versions are also available for the following:
Visual Basic Language Reference
Is Operator

Compares two object reference variables.

result = object1 Is object2

Parts

result
Required. Any Boolean value.
object1
Required. Any Object name.
object2
Required. Any Object name.

Remarks

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.

Example

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

© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker