Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Visual Basic 6 to .NET Migration

DZone's Guide to

Visual Basic 6 to .NET Migration

Read to learn all the pitfalls and benefits that come with a code migration, and how to use a certain tool the author has found effective.

· Web Dev Zone
Free Resource

Tips, tricks and tools for creating your own data-driven app, brought to you in partnership with Qlik.

Abstract

Modern Enterprises are forced into migrating their legacy systems due to key challenges like:

  • Maintainability.

  • Availability of skilled resources.

  •  Scalability.

  • Performance enhancements.

Migration of legacy VB applications can be done manually or using a tool like Artinsoft. Artinsoft is a leading tool for the migration of Visual Basic 6 to both Visual Basic .NET and C#. It is available in various models depending the on the size of the application we are looking to migrate.

The objective of this article is to help project teams foresee the issues that they might encounter after migrating their VB6 application using the Artinsoft tool. This will enable them to estimate their migration effort more accurately and plan accordingly. This article attempts to help you avoid the cost overruns and deliver the project on time. The article also lists out the best practices to be followed in the tool-based migration process based on some experience I've gained in past migration projects.

Abbreviations

Sl. No.

Acronyms (Page No.)

Full form

1

VB

Visual Basic

2

VBUC

Visual Basic Upgrade Companion

3

CR

Change Request

4

UI

User Interface


Market Trend

Market research by leading agencies suggests that over 70% of enterprise data resides in legacy software systems. Enterprises spend valuable resources and incur heavy costs in maintaining these legacy systems. These systems were developed more than a decade ago and have been updated over the years.

Legacy systems are upgraded for multiple reasons like bug fixes, improving performance, adding new features, etc. Some of the critical factors are listed below:

  • Maintaining legacy systems are very expensive due to the increased costs of current IT environments.

  • Shortage of skills for upgrading and maintaining the legacy systems.

  • Current employees have little or no knowledge about the critical business rules in the system as the logic has been implemented over the years by multiple developers. This leads to multiple rounds of regression testing for any minor fix or updates in the system.

  • Integration of the legacy systems with external or third-party applications is nearly impossible.

  • Performance improvement, scalability, adaptability, and interoperability are some of the other factors that contribute to migration.

Due to the above factors, enterprises have started thinking of legacy systems migration and it provides an immense market opportunity for the IT Firms in this domain.

Migration Issues

Following are some of the major issues that we may encounter after migration using Artinsoft. It’s very important to address these issues immediately after the migration to avoid bugs during testing.

Build Issues

Artinsoft uses advanced language transformation to migrate the VB6 code to .NET. It doesn’t guarantee that all the migrated code will have equivalent, compilable code in .NET. There may be issues in type casting, database record sets, UI control conversions, etc. The project team needs to have a plan of action to address these issues promptly.

Some issues are mentioned in the table below:

Build Issues

Sample Source Code

Sample Target Code

Resolution

String does not contain definition for Description

Conversion.ErrorToString().Description

Conversion.ErrorToString() .ToString()

Use ToString() instead of Description

Object does not contain definition for DisplayAlert, AsktoUpdateLinks, etc.

Object oExcel ;oExcel = new Excel.Application();

Excel.Application oExcel = new Excel. Application();

Create object directly.

Casting Issue with TimeZone to Int

Int tempAuxVar = TimeZone.CurrentTimeZone

int tempAuxVar = Convert.T    oInt32    (TimeZone.CurrentTimeZone);

 Casting with Convert.ToInt32

Artinsoft Warnings

Artinsoft includes various types of warnings in the code whenever it encounters any issues during the migration process. These warnings are based on the criticality of the migration issues. The developers need to analyze all the warnings, and, if required, they need to fix the issues manually.

Following are the various types of warnings included by Artinsoft.

UPGRADE_ISSUE

Artinsoft includes this warning when it’s not able to identify an alternate code in .NET. Developers can fix this warning by analyzing the original VB6 code and resolve it manually by including the equivalent .NET code. 

Example: AO.Database property dbSrc.QueryDefs was not upgraded, Listbar.ISSListItem property SListBar1.Groups.ListItems.IconLarge was not upgraded.

UPGRADE_TODO

This warning is included when Artinsoft migrated the code with the equivalent .NETsyntax, but it’s not sure if it’s the right conversion. This type of warning also requires analysis and the code needs to be fixed.

Example: Error handling statement (On Error Resume Next) was converted to a pattern that might have a different behavior.

UPGRADE_WARNING

This is similar to the above warning type but with less criticality. Developers can check the migrated code once and make sure the code will work as expected.

Example: Casting 'int' to Enum may cause different behavior.

UPGRADE_NOTE

This is basically an information type of warning and this doesn’t require any fix in the migrated code.

Example: The following declaration (cmdNew_Click) seems to be dead code.

Runtime Issues

The application may still not be stable even after fixing all the build and Artinsoft warning issues. Some issues will crop up during the runtime of the application and it can be identified only in the unit and functional testing of the application. There are various causes of these runtime issues like null pointer, dependency, unable to load UI controls, etc. All these runtime issues need to be identified and fixed with the appropriate code without affecting the existing business logic.

Best Practices

The Artinsoft migration issues can be resolved successfully by the below best practices which we have learned through our experience in earlier migration projects.

Pre-Migration Cleanup

The migration project requires some pre-migration analysis of the VB6 code before performing the actual migration. The project team should do a round of code cleanup/refactoring of the code by removing commented code, unused methods, and variables, etc., before baselining code for migration.

This improves the quality of output as the migrated application is free of redundant code which helps the project team to resolve issues efficiently.

Third-Party Control Analysis

Legacy VB6 applications might use a lot of native, as well as third-party, controls. Artinsoft will not be able to migrate all the third-party controls to .NET and this could create post-migration issues. Hence the migration team needs to capture the list of third-party controls used in the application in the pre-migration analysis phase and create a mapping document to match it with the .NET controls.

If the appropriate control is not available in .NET, then an alternative plan should be put in place before migration. The development effort for using the equivalent .NET control in the migrated application needs to be included in the estimation.

Fixing Artinsoft Issues (Warnings)

Artinsoft includes various types of warnings in the migrated code. It's advisable to fix all these warnings before running the migrated application, as it fixes 80% of the issues in runtime.

Code Review

Though Artinsoft migrates every single line of VB6 code to .NET, it’s better to do a manual code review after the migration. This is to make sure that no business logic has been missed or altered in the conversion. The manual code review can be done by comparing the original VB6 code with the migrated .NET code.

Fixing Bugs and Enhancements

If there are any bugs in the existing system, then it needs to be properly documented and clarified. The enhancement requests should be treated as CR and taken up accordingly.

Conclusion

Artinsoft is the preferred tool for the migration of VB6 applications to .NET and it has been recommended by Microsoft as well. The success of the migration project depends upon the effective usage of the tool and resolving the post migration issues on time.

The best practices given in this article are based on our experience in migrating a VB6 application to .NET using Artinsoft. The migration teams can apply these best practices in their project to leverage the maximum benefit out of the Artinsoft migration.

Explore data-driven apps with less coding and query writing, brought to you in partnership with Qlik.

Topics:
web dev ,code migration ,visual basic ,.net

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}