The quick, dirty, and somewhat incomplete—but still useful—way to meet the need of migrating code from Visual Basic 6 to VB.NET.is "Get the right tool for the job." To be a little less oblique, let me hasten to point out that any number of reputable development tools companies will happily sell you tools that they claim will automate as much as 98% of the work involved in moving a code base from VB 6 to VB.NET. I also believe that the bigger or more valuable the code base that needs to move from the older to the newer environment, the easier it will be to justify the costs involved. Some of the vendors that offer tools for this purpose include:
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
VB.NET itself also includes a "Conversion Wizard" that converts a subset of VB 6 code to VB.NET code. But before this conversion tool really helps much, most experts recommend that programmers perform some manual preparation to help adjust for the differences between the two language versions. In fact, most claim that the more (and better) the preparation, the fewer errors there will be to fix in the converted code output from that utility.
What's involved in this preparation process also helps clarify some important differences between VB 6 and VB.NET. Data types from VB 6 need to be reworked for VB.NET, particularly the variant data type, which accepts any form of data as input. Though this construct makes coding easy because it doesn't require strict definition of or typing for variables, it doesn't work in VB.NET, where object replaces variant. Among other things, this means searching VB 6 code for instances of variant, and replacing them with strongly typed variables or objects before using the Conversion Wizard on your code.
Something else that has to be eliminated during conversion is use of the goto on error statement. Though this has long been a convenient feature of Basic, it often adds to code complexity as well. VB.NET will force the introduction and use of more rigorous error identification and handling methods, and can therefore help to produce code that is easier to understand and maintain.
When the VB conversion tool is run, it flags any code it can't convert, and also provides links to additional explanatory information to explain what failed, and what kinds of solutions may be called for. But it's also important to consider that a rough and ready conversion doesn't do anything to exploit VB.NET's enhanced tools or capabilities. It's probably also desirable to conduct a design review and to consider which .NET features might be worth adding to a reworked application, since some effort to make the switch will be needed anyway. At the same time, it's probably also worthwhile to take additional steps to produce better modularized and more readable code as well.
By making the switch from VB 6 to VB.NET, a whole new world of features and functions become available. Careful combination of automated assistance, redesign, and reimplementation can produce better code than what is replaced. But it will take time, effort, and probably a bit of expenditure to carry the process to completion.
Here are a few other resources you may want to try.
Moving from Visual Basic to ASP.NET (Microsoft)
Using Visual Basic .NET (Microsoft)
Migrating from VB 6.0 to VB.NET – Some Tips (Dotnet Spider)
NeST Technology (NeST Technology)
Migrating applications from Visual Basic 6.0 to .NET (ELLKAY Solutions)
Migrating to VB.NET (Meghande Deshpande, SearchVB.com)
Ed Tittel is a full-time writer and trainer whose interests include XML and development topics, along with IT Certification and information security topics. E-mail Ed at email@example.com with comments, questions, or suggested topics or tools to review.