Various Datatypes employed by VB (uses If/Then & Case logic to explain):
Return to List
Public Sub Main()
' Dattype1.bas ' varA comes from another routine If VarType(varA) = vbEmpty Then
MsgBox ("The argument is Empty")
ElseIf VarType(varA) = vbNull Then
MsgBox ("The argument is Null")
ElseIf VarType(varA) = vbInteger Then
MsgBox ("The argument is Integer")
ElseIf VarType(varA) = vbLong Then
MsgBox ("The argument is Long")
ElseIf VarType(varA) = vbSingle Then
MsgBox ("The argument is Single")
ElseIf VarType(varA) = vbDouble Then
MsgBox ("The argument is Double")
ElseIf VarType(varA) = vbCurrency Then
MsgBox ("The argument is Currency")
ElseIf VarType(varA) = vbDate Then
MsgBox ("The argument is Date")
ElseIf VarType(varA) = vbString Then
MsgBox ("The argument is String")
ElseIf VarType(varA) = vbObject Then
MsgBox ("The argument is an Object")
ElseIf VarType(varA) = vbError Then
MsgBox ("The argument is an Error")
ElseIf VarType(varA) = vbBoolean Then
MsgBox ("The argument is Boolean")
ElseIf VarType(varA) = vbVariant Then
MsgBox ("The argument is a Variant array")
ElseIf VarType(varA) = vbDataObject Then
MsgBox ("The argument is a Data Object")
ElseIf VarType(varA) = vbDecimal Then
MsgBox ("The argument is Decimal")
ElseIf VarType(varA) = vbByte Then
MsgBox ("The argument is Byte")
Else
MsgBox ("The argument is an array")
End If
End Sub
' Can also use the VarType() function as below
Dim msg As Integer' MsgBox() return Select Case VarType(varA)' VarType() returns an integer Case 0
msg = MsgBox("The argument is Empty")
Case 1
msg = MsgBox("The argument is Null")
Case 2
msg = MsgBox("The argument is Integer")
Case 3
msg = MsgBox("The argument is Long")
Case 4
msg = MsgBox("The argument is Single")
Case 5
msg = MsgBox("The argument is Double")
Case 6
msg = MsgBox("The argument is Currency")
Case 7
msg = MsgBox("The argument is Date")
Case 8
msg = MsgBox("The argument is String")
Case 9
msg = MsgBox("The argument is an Object")
Case 10
msg = MsgBox("The argument is an Error")
Case 11
msg = MsgBox("The argument is Boolean")
Case 12
msg = MsgBox("The argument is a Variant array")
Case 13
msg = MsgBox("The argument is a Data Access Object")
Case 14
msg = MsgBox("The argument is Decimal")
Case 17
msg = MsgBox("The argument is Byte")
Case 8192
msg = MsgBox("The argument is an Array")
End Select
See also:
Ascii Character Code
Ascii Codes and Ranges
Cycling through a character string (in memory)