One of the serious problems when migrating large VB6 projects is that the resulting .NET project just contains too many compilation errors and they can’t be displayed in Visual Studio’s Error List window. In such cases it’s impossible to incrementally migrate and test the application. This article illustrates a simple migration technique that allows you to work around this problem.
Starting with version 1.31, VB Migration Partner supports a special pragma that automatically remarks all the statements inside a method body. You typically enable this option at the project level but disable it in selected forms, classes, and modules.
For example, let’s assume that you want to initially focus your migration efforts on the general purposes methods defined inside the Functions.bas module. You can achieve this by using these two pragmas at the top of the module itself:
The SetOption RemarkMethodBody pragma automatically comments all statements inside methods in all files except the current one. For example, here’s how a method might look like if it falls under the scope of the pragma:
Public Function DoubleIt(ByVal x As Single) As Single
End Function
Because it doesn’t remark also the method signature, all method and property references are correctly resolved, even if the call to that method or property actually does nothing. The important point is that you can work on a reduced number of compilation errors – that is, only those inside the Functions.vb module - and can start fixing them.
It is essential that you fix all the problems in Functions.vb exclusively by means of pragmas, so that your fixes will survive all subsequente migrations.
When all the compilation errors in Functions.vb have been fixed, you can turn your attention to another class or module, say the Widget class. To do so, just add this pragma at the top of the Widget.cls source file and re-run VB Migration Partner:
Instead of disabling this option at the file level, you can focus on single methods by inserting the pragma inside the method itself, as in this example:
Public Function DoubleIt(ByVal x As Single) As Single
...
End Function
Or you can just use Visual Studio’s Find and Replace command to eliminate the ' EXCLUDED prefix in front of each remarked line.