.NET Native Libraries instead of Visual Basic Compatibility Libraries

Whenever possible, the Visual Basic Upgrade Companion upgrades the VB6 libraries (i.e. VBA, VB) to .NET native equivalents instead of using the Visual Basic Compatibility Libraries.

The Visual Basic Upgrade Companion produces .NET code with minimal use of the Visual Basic Compatibility Runtime Library. While Artinsoft does not disagree with the use of this library, this more sophisticated VBUC approach is based on the following two guidelines:

  • Performance: native methods are faster in principle. The compatibility methods check for old VB6 behavior during runtime execution instead of a static analysis as VBUC does.
  • Maintainability: VB.NET allows old VB syntax to be used. With the Compatibility Runtime Library. For example, a developer can write Len(strVariable) instead of strVariable.Length. The resulting code is more difficult to read and maintain.

The following table shows other examples of the way the Visual Basic Upgrade Companion upgrades VB6 code using .NET Native Libraries.

Visual Basic 6.0 code
Dim i As Integer
Dim strvar As String
strvar = "Hello World"
i = Len(strvar)
MsgBox(i)
strvar = Left(strvar, 5)
MsgBox(strvar)
VB.NET: VB Upgrade Wizard generated code
Dim i As Short
Dim strvar As String
strvar = "Hello World"
i = Len(strvar)
MsgBox(i)
strvar = VB.Left(strvar, 5)
MsgBox(strvar)
VB.NET: Visual Basic Upgrade Companion generated code
Dim strvar As String = "Hello World"
Dim i As Short = strvar.Length
MessageBox.Show(CStr(i))
strvar = strvar.Substring(0, Math.Min(strvar.Length, 5)
MessageBox.Show(strvar)
C#: Visual Basic Upgrade Companion generated code
string strvar = "Hello World";
int i = (int) strvar.Length;
MessageBox.Show(i.ToString());
strvar = strvar.Substring(0, Math.Min(strvar.Length,5));
MessageBox.Show(strvar);