Home arrow VB.Net arrow Page 4 - Migrating to Visual Basic.NET from Visual Basic 6

Migrating to Visual Basic.NET from Visual Basic 6

Those already familiar with Visual Basic shouldn't have to worry about migrating to Visual Basic.NET. In this article Vaijayantee shows us how to upgrade our existing applications to Visual Basic.NET, different .NET variable types, and her own personal programming recommendations. After reading this article you'll be able to migrate from VB6 to VB.NET in no time!

Author Info:
By: Vaijayantee Sateesh Kamat
Rating: 4 stars4 stars4 stars4 stars4 stars / 47
April 08, 2002
  1. · Migrating to Visual Basic.NET from Visual Basic 6
  2. · Upgrading to Visual Basic.NET
  3. · Upgrade Report and Comments
  4. · Upgrade Report
  5. · Programming Recommendations
  6. · Control Changes in Visual Basic .NET
  7. · Summary

print this article

Migrating to Visual Basic.NET from Visual Basic 6 - Upgrade Report
(Page 4 of 7 )

We will have to check up with the Upgrade Report created by the Upgrade Wizard to find out what has happened. The report will be available in the Solutions Explorer. Double click it to open. Expand the Form2 node and you will see that the Upgrade Wizard has not been able to resolve the caption property of the Label1 on Form1.

Visual Basic .NET offers a different Windows Forms package. Which is provided by .NET framework.. Windows Forms and Windows Forms Controls provide a richer interface for developing Windows applications. This means that there are a number of differences between Visual Basic 6 forms and controls and Visual Basic.NET.

Now, open Form1 in the designer by double clicking on it. First thing to be noticed is the ToolTip Control. Remember Visual Basic.NET does not have ToolTip property for the objects? So, what it is trying to tell you is, if you want a ToolTip, add the control to the form.

Code changes

Let us now examine the code. The End command Button and Command2 Button do not require any modifications to the code. So, has the Upgrade Wizard really done any modifications to the code at all? Check the Form2 Command Button. Where is our call to the Show method of Form2?

Aha, here is where we see the real difference in Visual Basic 6 and Visual Basic.NET approach. Visual Basic.NET treats Forms as objects that belong to a class just like any other object and has to be instantiated before calling its methods. The DefInstance property creates an instance of Form2. This could have been handled by using New keyword, but this is just the Wizardís choice!

Now, open the Form2 code and rectify the error.

Change this code:

Label1.Text = frmdisplay.Label1.Caption


Label1.Text = Form1.DefInstance().Label1.Text

The application now runs smoothly.

Now, why did we have to do the modifications ourselves? Why could the wizard not do it? There are two solid reasons for this.

1) There is no exact one to one corresponding way to write the code between Visual Basic 6 and Visual Basic.NET

2) Visual Basic 6 code supports late binding and Visual Basic.NET does not.

Whenever the code encounters situations where it can not change the code, it prefers to draw programmerís attention to the problem and let the programmer do the job himself. There are four different types of warnings the wizard issues with the help of TO DO comments.
  • UPGRADE_ISSUES: Indicates compilation errors. These need to be corrected before the application can be compiled and run
  • UPGRADE_TODO: Though the project compiles well, there will be run time errors
  • UPGRADE_WARNINGS: Though the project compiles, there may be run time errors
  • UPGRADE_NOTE: This is a comment for information only. II tells us about any significant modifications handled by the wizard.
Also, when we open the code for Form1, we see it presented differently. Again, Option Explicit is automatically turned on and Option Strict turned off, allowing you to do some implicit conversions.

The block labeled Windows Form Designer also contains code for the design of the form. It tells us how the components on the form are generated, their locations, sizes etc. Though we can manually change this code, it is always a better idea to leave it to the designer. If we need any changes in the look and feel of the form, we could always go back to the designer and make the changes, isnít it?
blog comments powered by Disqus

- MyClass - Implementing Polymorphism in VB.Net
- Building a News Ticker Using VB.Net
- Everything You Wanted to Know About Forms In...
- Building Assemblies with VB.Net
- Simple VB.NET Notify Icon with Panel Applica...
- Regular Expressions in .NET
- String Encryption With Visual Basic .NET
- Deploying Applications in VB.NET: Part 1/2
- Watching Folder Activity in VB.NET
- Creating A Windows Service in VB.NET
- Implementing The Google Web Service In VB.NET
- Migrating to Visual Basic.NET from Visual Ba...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials