object1(required; Object or any reference type)
object2(required; Object or any reference type)
Compares two object variables or reference variables to determine whether they reference the same object
object2 must be reference-type variables.
This includes string variables, object variables, and array
variables, for instance.
The operation returns a result of
True if the
references are identical and
False if they are
It is also possible to determine whether an object contains a valid
reference by replacing
object2 with the
Nothing keyword. For example:
oDriveIs Nothing Then
does not refer to an object and
False if it does.
This is the only method that should be used to test for an
uninitialized object reference.
You can call the IsReference function to ensure
object2 are reference types.
You may wonder why there is a special
for reference types. When you perform a comparison of scalar
variables, you want to know if their values are the same. But in the
case of objects, you want to know if two references point to a single
object. (Since many objects have identical property values, a test
for equal values is meaningless.) Hence, the
operator is used for this purpose.
Is operator is used in an
If...Then...Else construct to take some action if two reference-type ...