There will be certainly a need to migrate applications developed with VB6 to VB.NET. Although simple programs can be migrated without any rework as the present note shows, projects with any complexity may need rework and research. This may lead to the conclusion that it may be easier to start from scratch. The following features in VB projects are not supported in the VB.NET environment:
- OLE Container Control
- Dynamic Data Exchange (DDE)
- DAO or RDO Data Binding
- Visual Basic 5.0 Controls
- DHTML Applications
- ActiveX Documents
- Property Pages
Migration Wizard Dialog
Visual Studio IDE has a menu item to bring up a wizard needed for migrating either VB or Java programs to .NET World. This can be accessed as shown. There also exists a way to convert VB code to VB.NET code which directly works with the code portion of the application. This helps to bring VB code to VB.NET, a small portion at a time instead of the whole project as in this note.
Clicking on Convert brings up the wizard as shown:
You can choose to convert either a VB or a Java application to be migrated to VB.NET. This is followed by the wizard explaining how this conversion will take place:
At this point, you will need to choose the project, *.vbp that you need to migrate, the Browse button may be used to bring in the project to the migration process. In this example, a very simple project called RevStr.vbp is being migrated.
The wizard can handle *.exe as well as *.dll type of projects. In the present case, it is a simple *.exe project.
In the next dialog, you need to select a location where your files can be located for the newly created VB.NET project. If you take the default, it will be created in a subdirectory of the project you are migrating, as in this case. Since it is creating a new directory, it will bring up a dialog to let you know that since the directory does not exist, it will create one as in the following screen:
This is all the information necessary for the upgrade. On clicking 'Next', the upgrade is made while you are watching the progress bar fill up.
Project Explorer and Solution Explorer
Whereas VB's Project Explorer had two forms with their code, the VB.NET migrated project has all the necessary class file references as shown here.
|VB Project||After Migration|
Code Changes to Files
Original Code for one of the forms:
Function MyReverse(ByVal S As String, ByVal Size As Integer) As String
Dim tmp As String: tmp = ""
Dim i As Integer
Dim x As Integer
If (Len(S) Mod Size) <> 0 Then
x = Len(S) Mod Size
tmp = tmp & Right(S, x)
S = Left(S, Len(S) - x)
For i = 1 To (Len(S) \ Size)
tmp = tmp & Right(S, Size)
S = Left(S, Len(S) - Size)
MyReverse = tmp
Private Sub Form_Load()
MsgBox (MyReverse("AXeBib", 3))
Changed Code after Migration
Hey, VB.NET has lot more stuff than VB6!!
Option Strict Off
Option Explicit On
Imports VB = Microsoft.VisualBasic
Friend Class Another
#Region "Windows Form Designer generated code "
Public Sub New()
If m_vb6FormDefInstance Is Nothing Then
If m_InitializingDefInstance Then
m_vb6FormDefInstance = Me
If System.Reflection.Assembly.GetExecutingAssembly.EntryPoint.DeclaringType _
Is Me.GetType Then
m_vb6FormDefInstance = Me
Protected Overloads Overrides Sub Dispose(ByVal Disposing As Boolean)
If Disposing Then
If Not components Is Nothing Then
Private components As System.ComponentModel.IContainer
Public ToolTip1 As System.Windows.Forms.ToolTip
Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New _
Me.components = New System.ComponentModel.Container()
Me.ToolTip1 = New System.Windows.Forms.ToolTip(components)
Me.ToolTip1.Active = True
Me.Text = "Form2"
Me.ClientSize = New System.Drawing.Size(312, 206)
Me.Location = New System.Drawing.Point(4, 30)
Me.StartPosition = _
Me.Font = New System.Drawing.Font("Arial", 8!, _
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.BackColor = System.Drawing.SystemColors.Control
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable
Me.ControlBox = True
Me.Enabled = True
Me.KeyPreview = False
Me.MaximizeBox = True
Me.MinimizeBox = True
Me.Cursor = System.Windows.Forms.Cursors.Default
Me.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.ShowInTaskbar = True
Me.HelpButton = False
Me.WindowState = System.Windows.Forms.FormWindowState.Normal
Me.Name = "Another"
#Region "Upgrade Support "
Private Shared m_vb6FormDefInstance As Another
Private Shared m_InitializingDefInstance As Boolean
Public Shared Property DefInstance() As Another
If m_vb6FormDefInstance Is Nothing OrElse m_vb6FormDefInstance.IsDisposed Then
m_InitializingDefInstance = True
m_vb6FormDefInstance = New Another()
m_InitializingDefInstance = False
DefInstance = m_vb6FormDefInstance
m_vb6FormDefInstance = Value
Function MyReverse(ByVal S As String, ByVal Size_Renamed As Short) As String
Dim tmp As String : tmp = ""
Dim i As Short
Dim x As Short
If (Len(S) Mod Size_Renamed) <> 0 Then
x = Len(S) Mod Size_Renamed
tmp = tmp & VB.Right(S, x)
S = VB.Left(S, Len(S) - x)
For i = 1 To (Len(S) \ Size_Renamed)
tmp = tmp & VB.Right(S, Size_Renamed)
S = VB.Left(S, Len(S) - Size_Renamed)
MyReverse = tmp
Private Sub Another_Load(ByVal eventSender As System.Object, _
ByVal eventArgs As System.EventArgs) _
Since it is anticipated that everything in VB may not go over to VB.NET, an upgrade report is also produced, which is a very nice thing. It also shows all the files and any facing issues in each of these files, as shown in the next and final screens. Besides some of the unsupported features mentioned in the beginning of this article, there will be other issues like graphics, Win32 APIs, legacy keywords etc.