SystemTypeName Function

   
SystemTypeName Function

Class

Microsoft. VisualBasic.Information

Syntax

 SystemTypeName(   vbname   ) 
vbname (required; String)

The name of a VB.NET data type

Return Value

A String indicating the name of a CTS data type

Description

Returns the fully qualified type name of the Common Type System (CTS) data type that corresponds to a particular Visual Basic data type

Rules at a Glance

  • vbname must be the name of a valid VB.NET data type, such as Boolean, Byte, Char, Date. Decimal, Double, Integer, Long, Object, Short, Single, or String.

  • If vbname is not a valid VB.NET data type, the function returns Nothing .

  • If vbname does not directly correspond to a CTS data type, the function returns Nothing . For example, user -defined types created with the Structure construct and classes created with the Class construct both return Nothing if their data type names are passed to the function.

Example

 Public Structure Point    Dim x As Integer    Dim y As Integer End Structure Public Class CEmployee End Class Module modMain Public Sub Main ' Returns System.Int32 Dim i As Integer = 100 Console.WriteLine("Type of i: " & SystemTypeName(TypeName(i))) ' Returns Nothing Dim o As Object Console.WriteLine("Type of o: " & SystemTypeName(TypeName(o))) ' Returns Nothing Dim oEmp As New CEmployee Console.WriteLIne("Type of oEmp: " & SystemTypeName(TypeName(oEmp))) ' Returns Nothing Dim uPt As Point Console.Writeline("Type of uPt: " & SystemTypeName(TypeName(uPt))) ' Returns System.String Dim sName As String = "This is a string." Console.WriteLine("Type of sName: " & SystemTypeName(TypeName(sName))) End Sub End Module 

Programming Tips and Gotchas

  • To determine the CTS data type of a particular variable, pass the variable as an argument to the TypeName function, and pass its return value as an argument to the SystemTypeName function. For example:

     strType = SystemTypeName(TypeName(myVar)) 
  • The existence of the SystemTypeName function clearly indicates that VB.NET data types are wrappers for CTS data types.

VB.NET/VB 6 Differences

The SystemTypeName function is new to VB.NET.

See Also

TypeName Function, VbTypeName Function

   


VB.Net Language in a Nutshell
VB.NET Language in a Nutshell
ISBN: B00006L54Q
EAN: N/A
Year: 2002
Pages: 503

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net