Returns a string (TypeName) or a numeric value (VarType) that contains information for a variable.
TypeName (Variable) / VarType (Variable)
String; Integer
Variable: The variable that you want to determine the type of. You can use the following values:
Keyword | Named constant | VarType | Variable type |
---|---|---|---|
Boolean | 11 | Boolean variable | |
Byte | 17 | Byte variable | |
Date | V-DATE | 7 | Date variable |
Currency | V-CURRENCY | 6 | Currency variable |
Double | V-DOUBLE | 5 | Double floating point variable |
Integer | V-INTEGER | 2 | Integer variable |
Long | V-LONG | 3 | Long integer variable |
Object | 9 | Object variable | |
Single | V-SINGLE | 4 | Single floating-point variable |
String | V-STRING | 8 | String variable |
Variant | 12 | Variant variable (can contain all types specified by the definition) | |
Empty | V-EMPTY | 0 | Variable is not initialised |
Null | V-NULL | 1 | No valid data |
5 Invalid procedure call
Sub ExampleType
Dim iVar As Integer
Dim sVar As String
Dim siVar As Single
Dim dVar As Double
Dim bVar As Boolean
Dim lVar As Long
Dim cVar as Currency
Dim tVar as Date
MsgBox TypeName(iVar) & " " & VarType(iVar) & Chr(13) &-
TypeName(sVar) & " " & VarType(sVar) & Chr(13) &-
TypeName(siVar) & " " & VarType(siVar) & Chr(13) &-
TypeName(dVar) & " " & VarType(dVar) & Chr(13) &-
TypeName(bVar) & " " & VarType(bVar) & Chr(13) &-
TypeName(cVar) & " " & VarType(cVar) & Chr(13) &-
TypeName(tVar) & " " & VarType(tVar) & Chr(13) &-
TypeName(lVar) & " " & VarType(lVar),0,"Some types in Office Basic"
End Sub