VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Porting VB 6.0. application to VB.Net environment.(Techncial article for thousands of developer)

by Bhuwan Chand Joshi (69 Submissions)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sun 10th June 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Porting VB 6.0. application to VB.Net environment.(Techncial article for thousands of developer)

Rate Porting VB 6.0. application to VB.Net environment.(Techncial article for thousands of developer)



' Author : Bhuwan Chand Joshi
' Article: Porting VB 6.0. application to VB.Net
 

This article is useful to the programmers who are planning to upgrade their Microsoft Visual Basic 6.0 applications to Microsoft VB.Net

VB.Net : A complete object oriented model.

VB.Net has been designed in such a way, it will convert previous version of visual basic to VB.Net automatically. But still you need to perform certain changes in your applications. For example you need to remove form resize code whenever you are upgrading it. This article is basically helpful to minimize your changes when you are converting your VB 6.0 applications to VB.Net applications. Always remember VB.Net is still in development.

VB.Net is an upgraded version of Visual Basic 6.0. Basically helpful in designing the distributed web applications and n-tier applications.

If you have your applications written in Visual Basic version 3 to 5, then first you need to convert it into VB 6.0. before upgrading it to VB.Net.

You can run both VB 6.0 and VB.Net on the same machine. Even you can use the activeXcontrols created by you in VB 6.0. inside the VB.Net environment.

In the VB.Net environment you have two types of forms: Windows Form and Web Forms.

Use Windows Forms for creating the windows based applications.

Use Web Forms for creating the web based applications.

In VB.Net environment, you have Web form which are basically HTML pages with Visual Basic events used for server side applications, you can also call it as ASP.Net

Webclasses of VB 6.0. are replaced with ASP.Net in VB.Net environment.

When your applications upgraded to VB.Net environment, Visual Basic Forms are converted into the Windows Form.

If you have your database based applications written using DAO, RDO data binding controls. So before converting to them into VB.Net, you need to convert them into ADO. You can use DAO, RDO only in codes in the VB.Net environment. ADO.Net introduces in the VB.Net environment which is helpful when you are creating the distributed applications.

You can use ADO.Net for disconnected data access.

Visual Basic has the variant data type. Now in VB.Net, variant and object data types are combined into a one data type : object type.

When your application upgraded to VB.Net the following changes will happen:

1. Integer data type converted into the Short data type.
2. Long data type converted into the Integer data type.
3. Property procedure will become as:

Property YourProperty() as Integer
    Get
    YourProperty=m_YourProperty
    End Get
    Set
    m_YourProperty=new_value
    End Set
End Property


In case of VB.Net, whenever you are playing with variables,you need to do explicit conversions as in Java because it might generate an error.

Don't use double with Date functions, it will generate compile error in VB.Net.

In Visual Basic 6.0. you can access the default properties of an object without using it as:

Dim ObjTextBox as Object
Set ObjTextBox=Text1
Msgbox objTextBox

The above code will create a problem in VB.Net environment.To resolve the above problem, your code will be as:

Dim ObjTextBox as Object
Set ObjTextBox=Text1
Msgbox objTextBox.Text 

In VB.Net you must have a lower bound array of zero while in case of visual basic 6.0, it is any whole number.

Avoid using the code given below VB.Net:

Dim Obj as Object
Set Obj=Form1
Obj.WindowState=1 ' This type of assigning constant values will create a problem 

The above code should be modified as:

Dim Obj as Object
Set Obj=Form1
Obj.WindowState=vbMaximized ' Use constant names 

If you have fixed length strings in your visual basic applications 6.0 as:

Dim YourName as String * 25 

The above is upgraded in VB.Net as:

Dim YourName as new VB6.FixedLengthString (25) 

You should avoid using these keywords given below:

Def
Computed GoTo/GoSub
GoSub/Return
Option Base 0|1
VarPtr, ObjPtr, StrPtr
LSet

Above keywords are removed from the VB.Net environment. 

Windows Forms of VB.Net does not support the Form.PrintForm method.

Clipboard object improved to System.Windows.Clipboard which have more functionality.

Windows Forms of VB.Net does not support OLE Container Control.

Windows Forms of VB.Net does not support shape Controls which you have in VB 6.0.

Windows Forms of VB.Net has two menu controls: MainMenu and ContextMenu but in case of VB 6.0 you have only one menu control.

Windows Forms of VB.Net does not support Dynamic Data Exchange.

Windows Forms of VB.Net does not support the Form.PrintForm method.

Many graphics method like Circle, CLS, Pset, Point are removed in VB.Net

You can use the concept of try and catch block statements to handle the exceptions in your applications in VB.Net which is not possible with VB 6.0.

Now all the Visual Basic add-ins are the Microsoft .Net add-ins, this is because of the same IDE. You can use them anywhere inside the .Net framework.

Use early binding of variables in VB.Net

VB.Net upgrade tool does the following things for you:

1. Convert the variant data types into the object data types.
2. Convert the Integer data types into the Short types.
3. Convert the Long data types into the Integer types.
4. Upgrade the non-zero bound arrays using array wrapper class.
5. Converts the Visual Basic Forms to Windows Forms. 

Null Propagation will generate a type mismatch error in VB.Net. You need to use IsNull() function where the Null is encountered, mainly in database based applications.

When you are calling procedures in VB.Net parentheses required around argument list in all the cases otherwise it will generate an error.

In VB.Net, the Immediate window is replaced with Immediate Window and Output Window. Use Debug.WriteLine instead of Debug.Print.

In VB.Net, While statement is ended with End While statement but in case of VB 6.0 While ended with Wend statement.

The statement for File I/O operations like:

Open "YourName.txt" For Input As #1

The above statement is upgraded to:

FileOpen( 1, "YourName.txt",OpenMode.Input ) 



Download this snippet    Add to My Saved Code

Porting VB 6.0. application to VB.Net environment.(Techncial article for thousands of developer) Comments

No comments have been posted about Porting VB 6.0. application to VB.Net environment.(Techncial article for thousands of developer). Why not be the first to post a comment about Porting VB 6.0. application to VB.Net environment.(Techncial article for thousands of developer).

Post your comment

Subject:
Message:
0/1000 characters