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...

By submitting your personal information, you agree to receive emails regarding relevant products and special offers from TechTarget and its partners. You also agree that your personal information may be transferred and processed in the United States, and that you have read and agree to the Terms of Use and the Privacy Policy.

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:

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.

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 etittel@techtarget.com with comments, questions, or suggested topics or tools to review.

0 comments

E-Mail

Username / Password

Password

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy