Convert VB6 to VB.NET

The migration process

  1. Decide whether to upgrade or not. There are program types that are best left in your current VB version. Projects that use UserControls, WebClasses, DHTML pages, VB's add-in model and other special techniques cannot easily be upgraded. Use a compatibility check tool to estimate what you can upgrade to VB.NET and how much work it will require. Alternatively, try to load your project in VB.NET and see the upgrade report for critical issues.
  2. Run the Add-in Code Advisor in VB 6.0 to help clean up any issues ahead of the migration.
  3. Remove dead and duplicated code. Start by deleting all the code your programs don't use. It is not uncommon to have 30-40% dead code in a medium or large sized project. Migrating that code means extra burden and no benefits. Additionally, you should consider joining any duplicated functions to reduce the amount of code even further. — Now, how do you know what code is dead or duplicated? Of course you can try to find that out manually, but if your goal is to minimize work, we strongly recommend that you get a decent source code analyzer to find the dead and duplicated code.
  4. Upgrade problematic syntax and controls. Use of certain syntax and control versions will cause you a lot of trouble. Take the Data control or VB5 Common Controls controls (ComCtl32.ocx or ComCt232.ocx), for example. You must upgrade to ADO data control or MsComCtl.ocx and MsComCt2.ocx, respectively. And, if you happen to be still in VB3 or VB4, you must port it to VB6 first. Obsolete syntax like GoSubs need to get removed, and you even need to prepare your conditional compilation (#If statements). Fortunately, you don't have to upgrade everything, only those things that the VB.NET upgrade wizard doesn't handle. Use a compatibility check tool that recommends what to fix now and what to leave as is.
  5. Fix your data declarations. If you've used a lot of Variants and undeclared variables, you're almost doomed. Now it's your final chance to add those Option Explicit statements and add proper type declarations to every Dim statement. Not only will this make your code more robust and optimized - it will also enable the upgrade wizard to properly port your code. Control object variable declarations are of special importance if you don't feel like writing half of your method and property calls again. In addition, certain array and user-defined structure definitions are going to change. Use a source code analyzer that lists the declarations requiring a fix.
  6. Load your code in VB.NET. Let the upgrade wizard do its job. You'll get a large report detailing the found upgrade issues, both fixed and unfixed. You'll get comments in the code near places that need to get worked on. What you're not getting is a list of undetected issues, of course.
  7. Try to compile your project. It won't succeed. You'll have a long list of compile errors. Now it really starts to pay off to be properly prepared. The list would be much longer if you hadn't prepared in advance.
  8. Go back. You might want to go back to step 1, 2, 3 or 4, fix some issues, and then go to step 5 and run the upgrade wizard again.
  9. Compile & fix cycle. Fix all the compiler issues. Finally, it runs.
  10. Fix the commented issues. The upgrade wizard left comments in your code. Find them and do what they say. Now it's also beneficial to review a list of expected behavior changes, like events that won't fire.
  11. Test. Now you're back to daily life. Run and test your program to make sure it works as expected.

VB6 to VB.NET migration process