Migrating VB6 code to Visual Studio .NET

In this topic

About migrating VB6 code to Visual Studio .NET

Code migration in this help system often refers to the process of migrating ArcGIS 8.3 code to use the modular architecture found in ArcGIS releases 9.0 onwards.
However, if you have existing Visual Basic (VB) 6 code, you may need to migrate this code to Visual Studio .NET code, as well as migrating between ArcGIS releases. Before beginning this process, consider your reasons for migrating. For more information, see the MSDN Web site for advice on making the decision of whether or not to upgrade.
Migration steps
The following outlines the typical migration steps from a VB6 8.3 to a .NET 9.x solution:
  1. If required, start by completing the conversion from ArcGIS 8.3 to use the 9.x modular architecture by using the code converter add-in.
  2. Prepare your VB6 project to help the upgrade work as efficiently and effectively as possible. For example, you should use early binding (declaring variables of a specific type rather than as an Object), zero-bound arrays (don't use Option Base 1), avoid the use of default properties, and avoid the use of keywords not supported in Visual Basic (VB) .NET (such as GoSub, VarPtr, ObjPtr, StrPtr).
For more information about the changes to make to VB6 code, see the MSDN Web site.
The VB6 Code Advisor add-in from Microsoft can be used to highlight potential problem areas in your VB6 code before you convert a project to .NET. For more information, see Common issues when migrating from VB6 to Visual Basic .NET.
  1. Open the VB6 project in Visual Studio .NET; your project will be identified as requiring an upgrade and the Visual Basic upgrade wizard appears allowing you to create a new VB .NET project. The wizard then performs a standard automated upgrade of your code.
  2. The conversion process is not 100 percent automated; there may be errors in your new VB .NET project. The upgrade wizard creates an upgrade report for you; review this report and correct all of the issues listed. In addition to the issues listed in the report, you may find there are other errors in your upgraded code that cannot be caught by an automated process—for this reason, review each line of code to ensure that your new project performs correctly.
You may encounter different issues in your upgraded code, but there are errors or issues that are often found in upgraded ArcObjects projects. For more information on these issues, see Common issues when migrating from VB6 to Visual Basic .NET.
  1. If your goal is to have C# code, then after having resolved issues in your upgraded VB .NET project, use an automated code converter to translate the VB .NET code into C# (search on the Internet to find these available products).
Alternatively, you may want to create a VB .NET or C# project, adding the required classes, forms and so on, then use an automatic converter on sections of business logic before adding this code manually to your new project. This approach may provide a cleaner implementation, but may take longer to complete. The code snippet converter in Visual Studio .NET may be useful here (open a VB .NET project and choose Upgrade Visual Basic 6 Code from the Tools menu).
A third approach may be to consider the migration as an opportunity to refactor your code to take advantage of new capabilities that you gain with the migration to VB .NET. This approach takes longer than the other approaches, but can have many benefits. 

See Also:

About the ArcGIS .NET code converter
Common issues when migrating from VB6 to Visual Basic .NET