Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

傳回提供 變數相關信息的 String

語法

TypeName ( varname )

必要的 varname引數 是包含任何變數的 Variant,除了使用者定義類型的變數以外。

註解

TypeName 傳回的字串可以是下列任一項:

傳回字串

變數

物件類型

類型為 objecttype 的物件

位元組

位元組值

整數

整數

長整數

Single

單精確度浮點數位

Double

雙精確度浮點數位

貨幣

貨幣值

Decimal

十進位值

日期

日期值

String

String

布林值

布爾值

錯誤

錯誤值

空白

初始化

Null

沒有有效數據

物件

一個物件

未知

類型不明的物件

不參照對象的物件變數


如果 varname 是 陣列,傳回的字串可以是任何一個可能傳回的字串, (或 Variant) 附加空括號。 例如,如果 varname 是整數數位, TypeName 會 傳回 「Integer()」。。

範例

附註: 下列範例示範如何在 Visual Basic for Applications (VBA) 模組中使用此函數。 如需使用 VBA 的詳細資訊,請在 [搜尋] 旁的下拉式清單中選取 [開發人員參考],並在 [搜尋] 方塊中輸入一個或多個字詞。

此範例使用 TypeName 函數傳回變數的相關信息。

Dim NullVar, MyType, StrVar As String
Dim IntVar As Integer, CurVar As Currency
Dim ArrayVar (1 To 5) As Integer
NullVar = Null ' Assign Null value.
MyType = TypeName(StrVar) ' Returns "String".
MyType = TypeName(IntVar) ' Returns "Integer".
MyType = TypeName(CurVar) ' Returns "Currency".
MyType = TypeName(NullVar) ' Returns "Null".
MyType = TypeName(ArrayVar) ' Returns "Integer()".

Need more help?

Want more options?

探索訂閱權益、瀏覽訓練課程、瞭解如何保護您的裝置等等。

社群可協助您詢問並回答問題、提供意見反應,以及聆聽來自具有豐富知識的專家意見。

Was this information helpful?

How satisfied are you with the translation quality?
What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×