Visual Basic six and Transferring to Visual Basic.NET part II
Report and Comments Promotion
There is no straightforward way to upgrade the existing Visual Basic 6 applications. Though the Upgrade Wizard handles many of the tasks for us, we have to do some modifications to the code manually. The different programming styles, some ambiguities like late binding, some not supported functions make it impossible to automate the task completely. Upgrading manually will not be possible without knowing Visual Basic.NET and the .NET framework. In other words, there is no shortcut for upgrading your existing applications.
First VB six Application and its up gradation
When you open a Visual Basic 6 application in Visual Basic.NET, the Upgrade Wizard steps in to guide you through the upgrade process. It creates a new Visual Basic.NET application leaving the original project untouched. Unless we are using Standard edition of Visual Basic .NET, upgrading Visual Basic 6 applications is an almost automatic process in Visual Basic .NET. When the project is upgraded, most of the code is modified to support new syntax and Visual Basic 6 forms are converted to Windows Forms. But, in most of the cases some manual modification is required because certain language features do not have any equivalent in Visual Basic.NET and also the automatic upgrade might not take any advantage of the new features in Visual Basic .NET.
The options from Upgrade Wizard
Create default interfaces for all public classes
If all public classes option is selected, interfaces will be generated for all public classes even if they are not implemented. If the project chosen is not a Standard Exe project, then this option specifies how interfaces will be generated in the new project. By default, interfaces will only be generated for public classes that are implemented by other classes in the project.
The project Location
By default the project will be placed in a child folder of the current project. Default name of the new project will be projectname.NET. After the upgrade is complete, the Upgrade Wizard creates an Upgrade report for the project, itemizing the problems if any. It also adds comments to the converted code. They are displayed in the task list window as "To DO" task. Each task is associated with a help topic with a link.
The type of project to create
We can choose to upgrade it to either exe or dll project, if the type of project chosen for upgrading is an Active X Exe or ActiveX Document Exe project. Then all the other projects this option is not available and the only other option available is already selected.
The task of the Upgrade Wizard
1. Add 3 Command Buttons, A Text Box and a label to the form. Name the Command Buttons: Cmdend, cmdForm2, command2.
2. Create a Project in Visual Basic six.
Code for inserting
1. To the Click event of Command2, Ask some Text to be displayed in the text Box.
2. Give the Label1 some caption.
3. Have a label on it.
4. In the form load event of this form, add Label1.Caption = Form1.Label1.Caption.
5. Open Visual Basic.NET and open the same project. The Upgrade Wizard starts automatically with a welcome screen.
6. Add a second form.
7. In the Click event of the cmdForm2, just add Form2.Show.
8. Add a Command Button and in the click event just add Unload Me.
9. Run and test the project in Visual Basic six.
10. When you are sure that the project is running alright, save it and close Visual Basic 6.
This is an important step. Unless the project is running well, the comments and report by the Upgrade Wizard might not be useful. Either the wizard may generate wrong code or might not know what to do.
11. To the Click event of Cmdend, just add End.
Conclusion
The wizard just shows its progress while it processes the project. Now that the wizard has upgraded the project, let us examine the report created by it check if any manual changes are needed.