VarType Function

VarType Function

Returns a value indicating the subtype of a variable.

(It is used to check data sub type of a variable or Value) 


Dim val, a(4)
Msgbox VarType(val) '0 for Empty/Uninitialized

Msgbox VarType(val) '8 for string

Msgbox VarType(val) '2 for Integer

Msgbox VarType(val) '8 for string

Msgbox VarType(val) '5 for Double

Msgbox VarType(val) '7 for Date

Set val = CreateObject("Scripting.FileSystemObject")
Msgbox VarType(val) '9 for Automation Object

Msgbox VarType(a(3))

a(0) ="India"
a(1) =10
a(2) =1.23
a(3) =#10/10/2000#

Msgbox VarType(a) '8204
Msgbox VarType(a(0)) '8
Msgbox VarType(a(1)) '2
Msgbox VarType(a(2)) '5
Msgbox VarType(a(3)) '7
Msgbox VarType(a(4)) '0

VarType Function Returns Constant based Result

VarType Function Constants

0 for Empty (uninitialized)

1 for Null (no valid data)

2 for Integer

3 for Long integer

4 for Single-precision floating-point number

5 for Double-precision floating-point number

6 for Currency

7 for Date

8 for String

9 for Automation object

10 for Error

11 for Boolean

12 for Variant (used only with arrays of Variants)

13 for A data-access object

17 for Byte

8192 for Array



Post a Comment