
344
|
Chapter 12: The Language Reference
This is the Title of the Book, eMatter Edition
Copyright © 2006 O’Reilly & Associates, Inc. All rights reserved.
See Also
MIRR Function
Is Operator
Syntax
Dim result As Boolean = object1 Is { object2 | Nothing }
object1 (required; Object or any reference type)
An object or instance for comparison
object2 (required; Object or any reference type)
An object or instance for comparison
Description
The Is operator compares two object references and indicates whether they refer to the
same underlying instance (
True) or not (False). It is most often used with If...Then...
Else statements, as in:
If (someVariable Is someOtherVariable) Then
' ----- Equivalent-specific code here.
End If
Comparing a variable with Nothing tests whether an instance has not yet been assigned
to that variable.
If (someVariable Is Nothing) Then
' ----- The variable is undefined.
End If
Usage at a Glance
• Both object1 and object2 must be reference-type variables. This includes string
variables, object variables, and array variables. You can call the
IsReference func-
tion to ensure that both
object1 and object2 are reference types.
• The Is operator can be used with the TypeOf operator to determine if an object
reference is of a specific type.
• The
Is operator reports that uninitialized reference types are equal. For example,
the following comparison equates to
True:
Dim emptyForm As Windows.Forms.Form