Visual Basic Language Reference  

VbTypeName Function

Returns a String value containing the Visual Basic data type name of a variable.

Public Function VbTypeName(ByVal UrtName As String) As String

Parameter

UrtName
Required. String variable containing a type name used by the common language runtime.

Remarks

VbTypeName returns the Visual Basic .NET type name corresponding to the common language runtime type name. For example, if UrtName contains "Int32" or "System.Int32", VbTypeName returns "Integer". If VbTypeName does not recognize the value of UrtName, it returns Nothing (not the string "Nothing").

The type name in UrtName can be obtained from various sources, for example from the Name property of the System.Type class.

Example

This example uses the VbTypeName function to return data type names for several variables.

Dim SysDateName As String = "System.DateTime"
Dim SysShortName As String = "Int16"
Dim SysBadName As String = "Nonsense"
Dim MyVbName As String
MyVbName = VbTypeName(SysDateName)   ' Returns "Date".
MyVbName = VbTypeName(SysShortName)   ' Returns "Short".
MyVbName = VbTypeName(SysBadName)   ' Returns Nothing.

See Also

Data Type Summary | String Data Type | Type Class | SystemTypeName Function