VB6 constants and numeric literals to .NET enumerations

A common practice in VB6 is to assign numeric literals to control properties. The Visual Basic Upgrade Companion replaces these literals with the .NET enumeration equivalents so that the generated VB.NET code is more legible and maintainable.

The Visual Basic Upgrade Companion will assign the corresponding .NET constant even when the programmer uses the wrong constant, helping remedy a common mistake in VB6. For instance, VB6 programmers frequently use a constant of FileAttibutes enumeration instead of the MousePointer enumeration. In VB6 this is not a problem because vbNormal and vbDefault have the same integer value.

In the example below, the Upgrade Wizard generates code including three EWI’s (Error Warnings and Issues) indicating that constants where not upgraded properly, while the Visual Basic Upgrade Companion declares variable num of type Forms.Cursors, instead of Short, and upgrades the numeric constant "11" to the .NET enum value System.Windows.Forms.Cursors.WaitCursor.

Visual Basic 6.0 code
Sub Foo()
    num = vbArrow
    Me.MousePointer = num
    Me.MousePointer = 11
    Me.MousePointer = vbArrow
End Sub
VB.NET: VB Upgrade Wizard generated code
Sub Foo()
    Dim num As Object
    'UPGRADE_WARNING: Couldn't resolve default property of object num.
    num = System.Windows.Forms.Cursors.Arrow
    'UPGRADE_WARNING: Couldn't resolve default property of object num.
    'UPGRADE_ISSUE: Form property Form1.MousePointer does not support custom mousepointers.
    Me.Cursor = num
    Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
    Me.Cursor = System.Windows.Forms.Cursors.Arrow
End Sub
VB.NET: Visual Basic Upgrade Companion generated code
Sub Foo()
    Dim num As Cursor = Cursors.Arrow
    Me.Cursor = num
    Me.Cursor = Cursors.WaitCursor
    Me.Cursor = Cursors.Arrow
End Sub
C#: Visual Basic Upgrade Companion generated code
void Foo()
    Cursor num =Cursors.Arrow;
    this.Cursor = num;
    this.Cursor = Cursors.WaitCursor;
    this.Cursor = Cursors.Arrow;