Contents
Index 🔎︎

# TypeName Function; VarType Function

傳回包含變數資訊的字串 (TypeName) 或數值 (VarType)。

### Syntax:

    TypeName (Variable) / VarType (Variable)

### Return value:

String; Integer

### Parameters:

Variable：要確定其類型的變數。您可以使用以下的值：

Keyword | Named constant | VarType | 變數類型
--- | --- | --- | ---
Boolean |  | 11 | 布林型變數
Byte |  | 17 | Byte variable
Date | V_DATE | 7 | 日期型變數
Currency | V_CURRENCY | 6 | Currency variable
Double | V_DOUBLE | 5 | 雙精度型浮點變數
Integer | V_INTEGER | 2 | 整數型變數
Long | V_LONG | 3 | 長型整數變數
Object |  | 9 | 物件型變數
Single | V_SINGLE | 4 | 單精度型浮點變數
String | V_STRING | 8 | 字串型變數
Variant |  | 12 | 變體型變數 (可包含由定義指定的所有類型)
Empty | V_EMPTY | 0 | 未初始化變數
Null | V_NULL | 1 | 無有效資料

### 錯誤代碼：

5 無效的程序呼叫

### Example:

    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 LibreOffice Basic"
    End Sub