excel vba vartype function code example

Example: vba varType get description

Function VarTypeDescription(var) As String
    Select Case VarType(var)
        Case vbEmpty: VarTypeDescription = "Empty (uninitialized)"
        Case vbNull: VarTypeDescription = "Null (no valid data)"
        Case vbInteger: VarTypeDescription = "Integer"
        Case vbLong: VarTypeDescription = "Long integer"
        Case vbSingle: VarTypeDescription = "Single-precision floating-point number"
        Case vbDouble: VarTypeDescription = "Double-precision floating-point number"
        Case vbCurrency: VarTypeDescription = "Currency value"
        Case vbDate: VarTypeDescription = "Date value"
        Case vbString: VarTypeDescription = "String"
        Case vbObject: VarTypeDescription = "Object"
        Case vbError: VarTypeDescription = "Error value"
        Case vbBoolean: VarTypeDescription = "Boolean value"
        Case vbVariant: VarTypeDescription = "Variant (used only with arrays of variants)"
        Case vbDataObject: VarTypeDescription = "A data access object"
        Case vbDecimal: VarTypeDescription = "Decimal value"
        Case vbByte: VarTypeDescription = "Byte value"
        Case vbLongLong: VarTypeDescription = "LongLong integer (valid on 64-bit platforms only)"
        Case vbUserDefinedType: VarTypeDescription = "Variants that contain user-defined types"
        Case vbArray: VarTypeDescription = "Array (always added to another constant when returned by this function)"
    End Select
End Function

Tags:

Vb Example