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

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
TABLE OF CONTENTS:
  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
SEARCH DEVARTICLES

Migrating to Visual Basic.NET from Visual Basic 6 - Programming Recommendations
(Page 5 of 7 )

In general, it will ease the life of the programmers who want to upgrade their Visual Basic 6 applications, if they keep following points in mind before they upgrade the applications. If they make some necessary changes in advance to their Visual Basic 6 application the upgrade process will definitely be smoother. Let us just go through some of the points that will help application your applications in Visual Basic 6 smoothly

Binding

Though both, Visual Basic 6 as well as Visual Basic.NET support late binding, it can cause problems in upgrade process when resolving default problems. In such cases, it is better to re-write the code using early binding

Let us examine the code written Visual Basic 6 using late binding.

Dim ObjLbl as Object

Set ObjLbl = Me.Label1

ObjLbl.Caption = "Hello"


This code works fine with Visual Basic 6. But, when we try to upgrade it to Visual Basic.NET, the caption property of a Label needs to be changed to Text property. The ObjLbl is type-less and the wizard has no way of knowing what properties it is supposed to change. If you change the first line of the code to “Dim ObjLbl as Label” then the code upgrades just fine.

Dates

Another thing to remember is the Date data type. We should use Date data type for storing dates because, unlike Visual Basic 6, Visual Basic.NET does not support double data type for storing dates.

Default Properties

It will help smoother upgrade if you specify default properties of the controls used in the code. In the above-mentioned code, using ObjLbl.Caption=”Hello” instead of using just ObjLbl = “Hello” will help the wizard in resolving the default property. Though the wizard will try to find out the default properties, it will not be always be successful. Again late bound default properties will inevitably fail.

Zero Bound Arrays

Visual Basic 6 supports arrays with lower bound even other than zero. You have to set the lower bound with LBound statement. When an application with array other than zero is upgraded, the Upgrade Wizard issues an UPGRADE_WARNING saying that the array is converted to LBound zero.

Windows APIs

As the underlying OS is the same, most of the API calls can be used in the same way. Some data types like Long are different than the Visual Basic 6 though here the Upgrade Wizard can take care of the changes. In some cases like Fixed Length Strings that Visual Basic.NET does not inherently support, can cause a problem for the Upgrade Wizard. Also, APIs that support thread creation or windows subclassing can cause a problem in Visual Basic.NET

Considerations for Forms and Controls

In general, we can say that keeping following changes in mind will help us in upgrading the Visual Basic 6 projects.

Forms tasks changes in Visual Basic.NET
  • Unlike Visual Basic 6, the tab order can be set using the Tab Order from View menu in Visual Basic .NET
  • Determining modifier keys for mouse and keyboard events is very different from Visual Basic 6. We have to find out value of the key using the keys enumeration and compare it to the class’s modifier method.
  • When we are aligning and sizing a control in Visual Basic 6, the last control in selection is the reference whereas in Visual Basic .NET it is the first control
  • For deciding the runtime position of the Form, Visual Basic 6 uses Startup property while Visual Basic .NET uses StartPosition property. Also, instead of Left and Top properties, Visual Basic.NET uses Location property by setting it to a point object
  • In Visual Basic .NET a GroupBox control is used instead of a Frame
  • In Visual Basic .NET, a controls collection used instead of a control array to iterate through the controls on the form.

blog comments powered by Disqus
VB.NET ARTICLES

- 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 
Support 

Developer Shed Affiliates

 




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