Returns the value of a variant after changing it from one data type to another

(vlax-variant-change-type var type)

The vlax-variant-change-type function returns the value of the specified variable after converting that value to the specified variant type.



A variable whose value is a variant.


The type of variant to return, using the value of var (the value of var is unchanged). The type value can be represented by one of the following constants:

vlax-vbEmpty (0) Uninitialized

vlax-vbNull (1) Contains no valid data

vlax-vbInteger (2) Integer

vlax-vbLong (3) Long integer

vlax-vbSingle (4) Single-precision floating-point number

vlax-vbDouble (5) Double-precision floating-point number

vlax-vbString (8) String

vlax-vbObject (9) Object

vlax-vbBoolean (11) Boolean

vlax-vbArray (8192) Array

The integer shown in parentheses indicates the value to which the constant evaluates. It is recommended that you specify the constant in your argument, not the integer value, in case the value changes in later releases of AutoCAD.

Return Values

The value of var, after converting it to the specified variant type; otherwise nil, if var could not be converted to the specified type.


Set a variable named varint to a variant value:

_$ (setq varint (vlax-make-variant
#<variant 3 5>

Set a variable named varintstr to the value contained in varint, but convert that value to a string:

_$ (setq varintStr (vlax-variant-change-type
varint vlax-vbstring))
#<variant 8 5>

Check the value of varintstr:

_$ (vlax-variant-value varintStr)

This confirms that varintstr contains a string.

See Also