Determines the data type of a variant
(vlax-variant-type var)
If var contains a variant, one of the following integers is returned:
0 Uninitialized (vlax-vbEmpty)
1 Contains no valid data (vlax-vbNull)
4 Single-precision floating-point number (vlax-vbSingle)
5 Double-precision floating-point number (vlax-vbDouble)
8192 + n Safearray (vlax-vbArray) of some data type. For example, an array of doubles (vlax-vbDouble) returns 8197 (8192 + 5).
If var does not contain a variant, an error results.
Set a variant to nil and display the variant's data type:
_$ (setq varnil (vlax-make-variant nil))
#<variant 0 >
_$ (vlax-variant-type varnil)
0
Set a variant to an integer value and explicitly define the variant as an integer data type:
_$ (setq varint (vlax-make-variant 5 vlax-vbInteger))
#<variant 2 5>
_$ (vlax-variant-type varint)
2
Set a variant to an integer value and display the variant's data type:
_$ (setq varint (vlax-make-variant 5))
#<variant 3 5>
_$ (vlax-variant-type varint)
3
Notice that without explicitly defining the data type to vlax-variant-variant, an integer assignment results in a Long integer data type.
Set a variant to a string and display the variant's data type:
_$ (setq varstr (vlax-make-variant "ghost"))
#<variant 8 ghost>
_$ (vlax-variant-type varstr)
8
Create a safearray of doubles, assign the safearray to a variant, and display the variant's data type:
_$ (setq 4dubs (vlax-make-safearray vlax-vbDouble '(0 . 3)))
#<safearray...>
_$ (setq var4dubs (vlax-make-variant 4dubs))
#<variant 8197 ...>
_$ (vlax-variant-type var4dubs)
8197
A variant type value greater than 8192 indicates that the variant contains some type of safearray. Subtract 8192 from the return value to determine the data type of the safearray. In this example, 8197-8192=5 (vlax-vbDouble).
Assign a real value to a variable, then issue vlax-variant-type to check the variable's data type:
_$ (setq notvar 6.0)
6.0
_$ (vlax-variant-type notvar)
; *** ERROR: bad argument type: variantp 6.0
This last example results in an error, because the variable passed to vlax-variant-type does not contain a variant.
-
The vlax-make-safearray, vlax-make-variant, vlax-variant-change-type, and vlax-variant-value functions.