We’ve heard suggestions that a double path approach is best for those who choose to migrate their VB6 applications to C#. This suggestion comes from those who offer a solution that only converts to VB.NET, and they say it’s irrational to even think about jumping from VB6 to any .NET language other than VB.NET. At Mobilize.Net, we know this advice is wrong and have proven it wrong hundreds of times.
The differences between Visual Basic 6.0 and any .NET framework compliant language is noticeable, since the former is a procedure intensive, non structured programming language which its strongest feature was the “visual” designer used to build the graphical user interface, while the latter languages are fully object oriented.
The differences between VB6 and C# or VB.NET are estimated and resolved in most scenarios by the Visual Basic Upgrade Companion tool. To be more specific, let’s use a VB6 inherent feature, which is also present in VB.NET by the way: the “OnError Goto” construct, an unstructured error handling technique to jump to a specified code segment, and “OnError Resume Next”, used to continue with the next instruction in the source code in case there is an error. Both structures make more complex the path tracking for the application control during runtime, and complicate the debugging process and increases the time needed for the application maintenance because of its complexity and lack of readability.
The VBUC is able to remove this error handling routines in the generated source code, ensuring the resulting source code will behave as much as object oriented as possible. The routine used to replace these structures is the “Try … Catch” blocks, simplifying the application flow path by having a managed interception of each error (exception). The “On Error GoTo” and “ResumeNext” constructs are not one-to-one equivalents with the “Try … Catch” block, but it is the simplest way to manage error occurrences without creating the same complexity effect found in the VB6 intrinsic routines.
The upgrade process from VB6 to C# is easier with the Visual Basic Upgrade Companion because of the considerations taken to ensure the resulting code’s quality will be the highest. Some of these considerations are strict typing, event declaration and invocation, error handling, refactoring from modules to classes, parameter transmission, arrays with lower bounds to zero, array dims and redims, default instances for forms, classes and user controls, indexer properties, “with” replacement for full naming, usage of return statements, interface creation for implemented classes, variable initialization, brackets and case sensitiveness refactoring, and more. After a deep analysis of the original source code, the Visual Basic Upgrade Companion is able to perform all the refactoring and transformations needed to accomplish all the previously listed items, delivering the greatest levels of automation and taking the VB6 to .NET migration to higher levels of excellence.
All the Visual Basic 6 inherited features in VB.NET which C# lacks can be modeled with different constructions to accomplish functional equivalence. Using those alternate constructions the code will look more C# native instead of a bizarre adaptation from two extremely different programming paradigms.
All this means that a VB6 to VB.NET upgrade will consume the same effort as migrating to C#. The Visual Basic Upgrade Companion’s architecture allows the C# generation to be done directly from the analysis over the original VB6 source code, allowing the upgrade process to be done in one strike.
This one-step migration avoids the use of third party tools to do the final step from VB.NET to C# because the resulting code is built directly into C# and not in a VB.NET intermediate representation. A two-step migration will ruin the overall precision of the upgrade task because two different tools may differ in the code refactoring techniques, resulting in poor source code quality with almost no readability.
Mobilize.Net has successfully upgraded billions of lines of code from VB6 to C#, and counting more everyday. Based on this experience we can assure you that a VB6 to C# migration is possible, reliable, and in fact, one of the most popular choices among large real world organizations.