Is Operator

Purpose

Used to compare two object reference variables

Syntax

Bool = object1 Is object2

Bool = TypeOf(object1) Is typename

Description

If object1 and object2 both refer to the same object, result is True; if they do not, result is False. Two variables can be made to refer to the same object in several ways.

In the following example, A has been set to refer to the same object as B:

Set A = B

The Is operator is an object reference comparison operator. It does not compare objects or their values; it checks only to determine if two object references refer to the same object.

The Is operator is also used together with TypeOf. In this case Is compares two OCX or OLE types.

Example

OpenW 1

Ocx TextBox tb1

Ocx TextBox tb2

Ocx Command bt1

Ocx Command bt2

Ocx Command bt3

Print tb1 Is tb2                // False

Set tb1 = tb2

Print tb1 Is tb2                // True

Set bt1 = bt3

Print bt2 Is bt1                // False

Print TypeOf(bt2) Is Command    //True

Remarks

When expressions contain operators from more than one category, arithmetic operators are evaluated first, comparison operators are evaluated next, and logical operators are evaluated last. The Is operator is evaluated last.

See Also

Set, TypeOf

{Created by Sjouke Hamstra; Last updated: 10/10/2014 by James Gaite}