Description

Casts the values in a Variant to another arithmetic type

Return Type

A McObject object.  

A McObject instance holding the cast Operand. The returned result will be of the arithmetic type specified by the CastToTypeName argument. It will also be the same shape as Operand, except that it will always be an array, even if the Operand is a scalar (generally there is no reason to use these vector operators unless you are dealing with arrays).

Syntax

object.McOpCast (Operand, CastToTypeName)

The McOpCast Method syntax has these parts:

PartDescription
objectAn expression evaluating to an object of type McOMGlobal.
OperandRequired. A Variant value.

May be a scalar or array of any arithmetic type. It may also be an McObject instance of an arithmetic type.

CastToTypeNameRequired. A String value.

Destination type for the case. Allowed names are “INTEGER” or “LONG” for 32-bit integer (VB Long type), “SHORT” for 16-bit integer (VB Integer type), “BYTE” for 8-bit unsigned integer (VB Byte type), “REAL” for 64-bit IEEE floating point (VB Double type) or “FLOAT” for 32-bit IEEE floating point (DB Single type).

Remarks

The Operand (which may be a scalar or an array of arthmetic values) is converted to a requested destination type.

Casting can be especially important when using these vector operations, because the association rules for both arithmetic and logical binary operations (E.g. McOpAdd or McOpGT) always cast the right operand to the type of the left before performing the operation. Thus, McOpAdd( 1, 1.5) yields 2, not the intuitively expected 2.5; McOpAdd(McOpCast(1,"REAL"),1.5) does give the expected result.

Exceptions

The Operand must scalars or arrays of some arithmetic type. Operands may be arrays of VARIANT, but if they are, all elements must be of the same arithmetic type. E.g., Array( 1, 2) is OK, but Array( 1.5, 2) is not legal.