Type Name conversion improvements
Additional support for the VB6 function TypeName was added in version 4.0.
The TypeName function is converted to the “is’ operator when used TypeName is used in a conditional statement.
Literal string values for types are changed to the corresponding type in .NET.
VB6 Code
Private Sub DisplayTypeName(ByVal obj As Object)
If TypeName(obj) = "Integer" Then
MsgBox("Integer")
End If
If TypeName(obj) = "String" Then
MsgBox("String")
End If
If TypeName(obj) = "CommandButton" Then
MsgBox("CommandButton")
End If
If TypeName(obj) = "myClass" Then
MsgBox("myClass")
End If
End Sub
.NET Code
private void DisplayTypeName( object obj)
{
if (obj is int)
{
MessageBox.Show("Integer", Application.ProductName);
}
if (obj is string)
{
MessageBox.Show("String", Application.ProductName);
}
if (obj is Button)
{
MessageBox.Show("CommandButton", Application.ProductName);
}
if (obj is myClass)
{
MessageBox.Show("myClass", Application.ProductName);
}
}