Share via


VbTypeName 函式

更新:2007 年 11 月

傳回的 String 值包含變數的 Visual Basic 資料型別名稱。

Public Function VbTypeName(ByVal UrtName As String) As String

參數

  • UrtName
    必要項。String 變數,包含 Common Language Runtime 所使用的型別名稱。

備註

VbTypeName 會傳回與 Common Language Runtime 型別名稱對應的 Visual Basic 型別名稱。例如,如果 UrtName 包含 "Int32" 或 "System.Int32",VbTypeName 則會傳回 "Integer"。如果 VbTypeName 無法辨識 UrtName 的值,它會傳回 Nothing (不是字串 "Nothing")。

您可從各種來源取得 UrtName 中的型別名稱,例如從 Type 類別的 MemberInfo 陣列中的 Name 屬性。

範例

下列範例使用 VbTypeName 函式,傳回幾個變數的資料型別名稱。

Dim sysDateName As String = "System.DateTime"
Dim sysShortName As String = "Int16"
Dim sysBadName As String = "Nonsense"
Dim testVbName As String
testVbName = VbTypeName(sysDateName)
' Returns "Date".
testVbName = VbTypeName(sysShortName)
' Returns "Short".
testVbName = VbTypeName(sysBadName)
' Returns Nothing.

需求

命名空間 (Namespace)︰Microsoft.VisualBasic

**模組︰**Information

組件:Visual Basic Runtime Library (在 Microsoft.VisualBasic.dll 中)

請參閱

參考

資料型別摘要 (Visual Basic)

String 資料型別 (Visual Basic)

SystemTypeName 函式