VarType

From Xojo Documentation
Jump to: navigation, search
Method

Used to determine the data type of a variable.

Syntax

result=VarType(value)

Part Type Description
result Integer Indicates the data type of value.
value Variant Value to be typed.

Notes

Result takes on the following values:

Result Variant Class Constant Description
0 TypeNil Nil
2 TypeInt32 Integer types of 32 bits or less, signed or unsigned. This is the replacement for TypeInteger.
3 TypeInt64 Int64 or UInt64. This is the replacement for TypeLong.
4 TypeSingle Single
5 TypeDouble Double
6 TypeCurrency Currency
7 TypeDate Date
8 TypeString String
9 TypeObject Object
11 TypeBoolean Boolean
16 TypeColor Color
18 TypeCString CString
19 TypeWString WString
20 TypePString PString
21 TypeCFStringRef CFStringRef
22 TypeWindowPtr WindowPtr
23 TypeOSType OSType
26 TypePtr Ptr
36 TypeStructure Structure
37 TypeText Text
4096, logically OR'ed with the element type. TypeArray Array

In the case of an array, the result is 4096 logically OR'ed with the array element type. You can get the element type by calling Variant.ArrayElementType. See the example for getting the VarType of an Integer array.

Examples

The following line of code returns 8 (data type of String):

Dim dataType As Integer = VarType("Herman")

The following returns 4098 (data type of an array (4096) logically OR'ed with the VarType of the element type of Int32 (2)).

Dim a(2) As Int32 = Array(0, 1, 2)
Dim dataType As Integer = VarType(a) // 4098

See Also

Variant class, Boolean, CFStringRef, Color, Currency, CString, Delegate, Double, Int8, Int16, Int32, Int64, Integer, OSType, PString, Ptr, Single, String, Structure, UInt8, Uint16, UInt32, UInt64, WindowPtr, WString data types; IsNumeric, Nil functions.

Personal tools
Namespaces

Variants
Actions
Main
Content
Starting Out
Dig Deeper
More Help
Toolbox
About