VB 6.0 to VB.NET Migration Command Line Arguments Issue






4.83/5 (10 votes)
Command line arguments issue when we migrate a VB 6.0 application to VB.NET using the VB.NET upgrade wizard
Introduction
When we migrate a Visual Basic 6.0 application to Visual Basic .NET using Visual Basic .NET upgrade wizard in Visual Studio .NET 2003, we have to take care of certain areas in the migrated application for smoother execution. This article will discuss one of the key areas, called command line arguments, which we need to consider as post-migration changes in the upgraded Visual Basic .NET application.
Visual Basic Command Line Arguments
One of the main features of Visual Basic is the ability to accept command-line parameters when an application is executed. Even with a GUI available to you, there are some cases in which you need to build a VB application that doesn't have a front-end. In these cases, one of the easiest ways to control the function of the application is through command line arguments. Command line arguments are passed into Visual Basic by way of the Command$
variable. This variable is a very long string with all the arguments written exactly as the user entered them. When running an application, you would add them to the shortcut or the Run
line.
Visual Basic 6.0 to Visual Basic .NET Migration
Microsoft has provided the Visual Basic .NET upgrade wizard as part of the Visual Studio .NET 2003 IDE. It assists the user with upgrading an existing Visual Basic 6.0 application to a Visual Basic .NET application with minimal effort. The wizard makes all the necessary syntax changes. The Visual Basic 6.0 forms and controls are upgraded into the proper Windows Forms and controls in Visual Basic .NET.
However, there are many features in Visual Basic 6.0 applications that are not upgraded by the wizard. This is primarily due to the very significant differences in the syntax and the architecture between Visual Basic 6.0 and Visual Basic .NET. The upgrade wizard provides a good starting point for the migration because it upgrades the basic features of the Visual Basic 6.0 application. Post-migration changes have to be done in Visual Basic .NET code to make it work in the Microsoft .NET environment, based on the issues identified in the upgrade report.
Command Line Argument Issue
The upgrade wizard will not identify all the issues while upgrading from Visual Basic 6.0 to Visual Basic .NET. One of the key issues is that the upgrade wizard will not identify the command line arguments from the project properties of the existing Visual Basic 6.0 application. If the existing Visual Basic 6.0 application has command line arguments then the upgrade wizard does not take those command line arguments to Visual Basic .NET. We have to copy this command line information manually and put in the Visual Basic .NET debugger. To do this, we have to proceed with the following steps...
Identify the Command Line Argument from the Existing Visual Basic 6.0 Application
- Open the Visual Basic 6.0 application's project
- Select Properties from the Project menu
- Click the Make tab
-
As shown below, check if there are any arguments in the Command Line Arguments box that the application takes
- If you have found any arguments listed as similar to the above, then copy these argument values.
Set Command Line Arguments in the Visual Basic .NET Application
Once the upgrade wizard completes the migration from Visual Basic 6.0 to Visual Basic .NET, from the Visual Basic .NET project IDE:
- Open the migrated Visual Basic .NET application solution
- Select Properties from the Project menu
- Click Configuration Properties from the left-hand side pane and click on Debugging
- Select Debug from the Configuration dropdown.
- As shown below, paste the command line arguments which we have copied in the previous section in the Command Line Arguments box under the Start Options section
- Click the Apply button
- Now select Release from the Configuration dropdown
- Again, paste the command line argument which we have copied in the previous section in the Command Line Arguments box under the Start Options section
Note: Here we are pasting the copied command line arguments for both Debug and Release mode builds.
- Click Apply and then click the OK button
Conclusion
Doing these manual changes will help the migration process go smoother and faster. Similarly, the developer has also to take other configuration items which are done in the existing Visual Basic 6.0 application while upgrading to Visual Basic .NET.