MS-Excel / General Formatting

The Is Operator

When you looked at comparison operators in the last tutorial, the operands you used were simple numbers and strings. Indeed, most of the comparison operators don't make sense in the context of objects (for example, it's absurd to think of one object being "greater than" another). However, VBA does have a comparison operator specifically for objects-the Is operator:

result = Object1 Is Object2

Here, Object1 and Object2 are objects or Object variables. If they're the same object, result takes the value True; otherwise, result is False.

[Previous] [Contents] [Next]