Click here to Skip to main content
15,606,617 members
Articles / Programming Languages / Visual Basic
Posted 15 Aug 2004


41 bookmarked

On Migrating a VB Project to VB.NET

Rate me:
Please Sign up or sign in to vote.
4.00/5 (11 votes)
20 Aug 20043 min read
Describes the migration of a simple VB project to VB.NET.


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.

Image 1

Clicking on Convert brings up the wizard as shown:

Image 2

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:

Image 3

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.

Image 4

The wizard can handle *.exe as well as *.dll type of projects. In the present case, it is a simple *.exe project.

Image 5

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:

Image 6

Image 7

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.

Image 8

Image 9

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 ProjectAfter Migration
Image 10Image 11

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)
    End If

    For i = 1 To (Len(S) \ Size)
        tmp = tmp & Right(S, Size)
        S = Left(S, Len(S) - Size)

    MyReverse = tmp
End Function

Private Sub Form_Load()
MsgBox (MyReverse("AXeBib", 3))
End Sub

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
  Inherits System.Windows.Forms.Form
#Region "Windows Form Designer generated code "
 Public Sub New()
  If m_vb6FormDefInstance Is Nothing Then
    If m_InitializingDefInstance Then
       m_vb6FormDefInstance = Me
      'For the start-up form, the first instance created is the
      'default instance.
      If System.Reflection.Assembly.GetExecutingAssembly.EntryPoint.DeclaringType _
                                   Is Me.GetType Then
        m_vb6FormDefInstance = Me
      End If
     End Try
    End If
  End If
   'This call is required by the Windows Form Designer.
 End Sub
 'Form overrides dispose to clean up the component list.
 Protected Overloads Overrides Sub Dispose(ByVal Disposing As Boolean)
  If Disposing Then
   If Not components Is Nothing Then
   End If
  End If
 End Sub
 'Required by the Windows Form Designer
 Private components As System.ComponentModel.IContainer
 Public ToolTip1 As System.Windows.Forms.ToolTip
 'NOTE: The following procedure is required by the Windows Form Designer
 'It can be modified using the Windows Form Designer.
 'Do not modify it using the code editor.
 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!, _
             System.Drawing.FontStyle.Regular, _
             System.Drawing.GraphicsUnit.Point, _
             CType(0, Byte))
   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"
 End Sub
#End Region 
#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
     End If
     DefInstance = m_vb6FormDefInstance
   End Get
       m_vb6FormDefInstance = Value
   End Set
 End Property
#End Region
'UPGRADE_NOTE: Size was upgraded to Size_Renamed. Click for more: 
'ms- help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1061"'
 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)
   End If

   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
 End Function

 Private Sub Another_Load(ByVal eventSender As System.Object, _
    ByVal eventArgs As System.EventArgs) _
    Handles MyBase.Load
        MsgBox(MyReverse("AXeBib", 3))
 End Sub
End Class

Upgrade Report

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.

Image 12


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Written By
Technical Writer Hodentek
United States United States
Worked in the area of electrical discharges, high energy lasers, high voltage technology, plasma technology, lithography, thin film plastics, superconducting thin films, diamond thin films, electron accelerators, and free electron lasers for several years. Mentored/guided MS and PhD students at several universities in USA, Brazil, Australia, and India.
Reading books and photography are my hobbies.

Also trained workforce clients with legacy computer skills in web related technologies.

I recently authored a beginner level book on MS SQL Server Integration Services. Details available at the following link:

My second book was released in 2008
Learn SQL Server Reporting Services 2008

Get book details at the following site:

This is for anyone who is interested in Reporting Services a la Microsoft. It has over 50 hands-on exercises and covers all aspects of Reporting Services.

Recent new books:

Microsoft SQL Azure Enterprise Application Development 2010
-A Comprehensive book on SQL Azure

Microsoft Visual Studio LightSwitch Business Application Development 2011
A step-by-step approach that is sure to work

Learning SQL Server Reporting Services 2012 Packt Publishers, ISBN: 978-1-84968-992-2 , 2013

Comments and Discussions

GeneralMy vote of 3 Pin
NaveenSoftwares18-Oct-10 0:32
NaveenSoftwares18-Oct-10 0:32 
GeneralRe: My vote of 3 Pin
mysorian18-Oct-10 4:03
professionalmysorian18-Oct-10 4:03 
GeneralRetrieving COM class error Pin
NaveenSoftwares18-Oct-10 0:29
NaveenSoftwares18-Oct-10 0:29 
GeneralVB6 to C#.Net Pin
Md. Ismail7-Jun-10 20:50
Md. Ismail7-Jun-10 20:50 
GeneralRe: VB6 to C#.Net Pin
NaveenSoftwares18-Oct-10 0:30
NaveenSoftwares18-Oct-10 0:30 
GeneralRe: VB6 to C#.Net Pin
rdunnill21-Dec-19 20:46
rdunnill21-Dec-19 20:46 
Generalvb6 to vb 2008 Excel Conversion problem Pin
D.Manivelan8-Feb-10 19:43
D.Manivelan8-Feb-10 19:43 
Hi friends,
I was create a project in vb6. this project purpose is integrate excel. now am converted in vb 2008. it working fine but form could not visible form status, after load excel this will show while working i could not view the form. how can i solve this problem. help me...
Generalerror in convertion Pin
PremaP15-Jan-10 17:47
PremaP15-Jan-10 17:47 
GeneralRe: error in convertion Pin
mysorian16-Jan-10 3:53
professionalmysorian16-Jan-10 3:53 
GeneralExcel related application program Pin
vijayalaya11-Aug-09 22:46
vijayalaya11-Aug-09 22:46 
GeneralRe: Excel related application program Pin
mysorian12-Aug-09 0:49
professionalmysorian12-Aug-09 0:49 
GeneralRe: Excel related application program Pin
mysorian16-Jan-10 3:50
professionalmysorian16-Jan-10 3:50 
GeneralProblem in conversion of reports Pin
cmrhema17-Mar-08 1:52
cmrhema17-Mar-08 1:52 
Generalproblem in conversion Pin
Sherrif15-Aug-06 1:14
Sherrif15-Aug-06 1:14 
GeneralRe: problem in conversion Pin
mysorian15-Aug-06 3:57
professionalmysorian15-Aug-06 3:57 
Generalexperience with ... Pin
SpeedySpeedy20-Aug-04 0:58
SpeedySpeedy20-Aug-04 0:58 
GeneralRe: experience with ... Pin
mysorian20-Aug-04 4:06
professionalmysorian20-Aug-04 4:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.