Determines the data type of a variant
(vlax-variant-type var)
Arguments
A variable whose value is a variant.
Return Values
If var contains a variant, one of the following integers is returned:
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) of some data type. For example, an array of doubles (vlax-vbDouble) returns 8197 (8192 + 5).
8192 + n Safearray (If var does not contain a variant, an error results.
Examples
nil and display the variant's data type:
Set a variant to_$ (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
vlax-vbDouble).
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-variant-type to check the variable's data type:
Assign a real value to a variable, then issue_$ (setq notvar 6.0)
6.0
_$ (vlax-variant-type notvar)
; *** ERROR: bad argument type: variantp 6.0
vlax-variant-type does not contain a variant.
This last example results in an error, because the variable passed tovlax-make-safearray, vlax-make-variant, vlax-variant-change-type, and vlax-variant-value functions.
The