Type Conversions

The Is Operator

Result = Operand1 Is Operand2;

The first operand is an object, the second operand is a class, interface or data type. Executing the operator results in a logical value showing whether the first operand can be cast to the class or the interface specified in Operand2.

It returns True if the object is relevant to the specified class (the object of this class or the class is a parent) or implements the specified interface.

If the conversion to a data type is checked, it is necessary to remember that the conversion is considered possible even when the data is partially lost. Remember this when working with data via the Variant type.

The As Operator

Result = Operand1 As Operand2;

The first operand is an object, the second one is a class or an interface. Executing the operator results in an object cast to this class or the interface pointer. If the cast has been completed unsuccessfully, an exception is thrown. The cast is available if the object is relevant to this class (the object of this class or the class is the parent) or implements the specified interface. An implicitly typed array can be specified as the second operand. If array size should be specified, correct transformation requires that it should match the size of the array passed in the first operand.

See also:

Fore Language Guide