VB6 vs VB.NET controls - Form object

This section describes the differences between VB6 and .NET controls and the problems you can find in migrating VB6 applications with user-interface. The differences that are common to most controls are described in the Controls (general) section.

For a list of differences between VB6 and VB.NET language, see here.

Unless otherwise stated, VB Migration Partner fully supports all the Visual Basic 6 features mentioned in this page. It is worth noticing that names of properties and methods are preserved, which ensures that those even late-bound references work correctly after the migration to VB.NET. For more information, please read the manual and the knowledge base section.

Form object

Activate and Deactivate events

Not only does VB.NET rename these events to Activated and Deactivated, there is also another behavioral difference: the VB6 Activate and Deactivate events fire when moving to another form of the same application, but don’t fire if the end user gives the input focus to a different application.

Another significant difference is that VB6 fires no event when a MsgBox or InputBox is executed, whereas VB.NET fires a Deactivated event for the form that was current, and then an Activated event when the message box is closed.

BackColor property

When you set the BackColor property in VB6 you indirectly clear the form’s background, as if you had executed a Cls method.

VB Migration Partner correctly replicates this behavior in converted VB.NET applications.

BorderStyle property

The VB6 BorderStyle property maps to the VB.NET FormBorderStyle property. The two properties behave similarly in the two languages, but the correspondence isn’t perfect. For example, a VB6 form has no caption Caption is an empty string and ControlBox is False, or if BorderStyle=vbSBNone; a VB.NET form has no caption only if FormBorderStyle=None.

Controls collection

The VB6 Controls collection includes all the controls hosted on the form, including controls that are contained in a child control (e.g. the radio buttons contained in a Frame control) and controls that are invisible at runtime (e.g. menus, timers, and common dialogs). By contrast, the VB.NET Controls collection contains only the visible controls that sit directly on the form’s surface.

The VB6Form class in VB Migration Partner’s support library exposes the Controls6 collection that behaves like the original VB6 object. This approach guarantees that For Each loops that iterate over the Controls collection delivers the same results as in the original VB6 application.

Controls.Add method

VB6 developers can dynamically create new controls by means of the Add method exposed by the Controls collection of the Form and the UserControl class, as in this example:

        ' Create a new TextBox control named "txtName"
        Dim tb As Text
        Set tb  = Controls.Add("VB.Text", "txtName")

The VB.NET Controls collection has an Add method, but it has a different meaning and a different syntax. This is the VB.NET code that is roughly equivalent to the above listing:

        Dim tb As New TextBox
        tb.Name = "txtName"

The Upgrade Wizard isn’t capable to convert the Controls.Add method, therefore equivalent code must be inserted manually. VB Migration Partner fully supports the Controls.Add method.

FontTransparent property

VB.NET forms don’t support the FontTransparent property; background text and graphic on a VB.NET form are always visible and there is no simple way to simulate the VB6 FontTransparent property in a .NET Framework application.

Forms in the VB Migration Partner’s support library expose the FontTransparent property, but it always returns True; attempts to assign a different value are ignored (or throw a runtime exception if the VB6Config.ThrowOnUnsupportedMembers property is set to True). This property is marked as obsolete and a migration warning is emitted when the property is referenced in code.

ForeColor property

Assigning the ForeColor property in VB6 simply selects the color that will be used for subsequent Line, Circle, or Print methods. Assigning the ForeColor of a VB.NET form can actually affect the form’s appearance - for example, it can change the color of the border around push buttons.

VB Migration Partner fully duplicates the original VB6 behavior under VB.NET.

Hide methods

The Hide method fires the FormClosing event under VB.NET, but it fires no events under VB6, therefore the converted VB.NET might receive these events at the wrong time.

VB Migration Partner ensures that no events are fired when the Hide method is called, thus preserving the VB6 behavior.

MaxButton, MinButton

These  properties have been renamed MaximizedBox and MinimizeBox, respectively. There is also another behavioral difference: no maximize or minimize buttons are showed if the BorderStyle property is set to 3-vbFixedDialog under VB6.

MdiChild property

This property has been renamed IsMdiChild under VB.NET. Moreover, under VB6 this property can be assigned to transform a standard form into an MDI child form, or vice versa. This isn’t possible under VB.NET, because the IsMdiChild property is read-only. (Under VB.NET you achieve this effect by assigning the form’s MdiParent property.)

VB Migration Partner fully supports the writable MdiChild property.

Moveable property

VB6 forms support the Moveable property: if this property is set to True then the end user can’t move the form. No similar property exists in the .NET Framework.

VB Migration Partner fully supports this property.

Palette and PaletteMode properties

VB.NET forms don’t support the Palette and PaletteMode properties, and there is no direct way to simulate these VB6 properties.

Forms in the VB Migration Partner’s support library expose the Palette and PaletteMode properties, but they always returns Nothing and 0-Halftone, respectively; attempts to assign different value are ignored (or throw a runtime exception if the VB6Config.ThrowOnUnsupportedMembers property is set to True). These properties are marked as obsolete and a migration warning is emitted when these properties are referenced in code.

Popup method (context menu)

VB.NET doesn’t support the PopupMenu method; instead, you must assign a ContextMenuStrip object to the ContextMenuStrip property of the form or the control on whose surface the context menu must appear. You don’t need to trap the MouseDown event if the menu has to appear when the end user right-clicks on the control, because this logic is built in the ContextMenuStrip control.

In spite of the deep differences between the VB6 and VB.NET programming models, VB Migration Partner fully supports the PopupMenu method, except that the flags and boldCommand parameters are ignored: all context menus are left-aligned and no command is shown in boldface. X and Y coordinates, if provided, are correctly converted from twips or whatever the current ScaleMode is.

PrintForm method

VB.NET doesn’t support the PrintForm method. The 2008 edition of Upgrade Wizard converts this method using Microsoft Power Pack library.

VB Migration Partner fully supports this method when migrating to either VB 2005 and 2008; no dependence from the Power Pack library is added.

QueryUnload event

This event isn’t supported. The closes equivalent under VB.NET is the FormClosing event. The event handler can detect the reason why the form is being closed by inspecting the CloseReason property of the FormClosingEventArgs object passed to the event handler; however, not all the possible reasons are supported directly.

VB Migration Partner supports the QueryUnload event and deduces the correct value for the reason argument passed to the event handler.

Resize event

VB.NET supports this event, which can be fired even when the form is still invisible. Conversely, VB6 never fires this event when the form is invisible, therefore a converted VB.NET application might behave differently from the original VB6 code and a runtime error might occur.

VB Migration Partner fires this event only when the form is visible, hence it guarantees that the original behavior is implemented.

Show method

VB6 can display both modal and modeless forms by means of the Show method (if the method’s first argument is nonzero, the form is displayed modally):

        Dim frm As New Form1
        frm.Show  1                    ' displays modal form
        frm.Show                       ' displays modeless form

VB.NET uses two different methods for these task: Show for modeless forms and ShowDialog for modal forms:

        Dim frm As New Form1()
        frm.ShowDialog()               ' displays modal form
        frm.Show()                     ' displays modeless form

The second argument of VB6’s Show method allows to assign the owner of the form being displayed; an owned for is automatically closed or minimized when the owner form is closed and minimized, and an owned window is always displayed in front of its owner. (For these reasons, owned forms are often used to implement floating palettes of icons and commands.):

        Dim frm As New Form1
        frm.Show ,Me                   ' display a modeless form, make the current form own it

In VB.NET you reach the same effect by means of the AddOwnedForm method:

        Dim frm As New Form1
        Me.AddOwnedForm(frm)           ' make the current form own the new form
        frm.Show()                     ' display the form

VB Migration Partner fully supports the Show method and all its optional arguments.

Show method (MDI child forms)

If you use the Show method to display an MDI child form under VB6, the method automatically loads and displays the MDI parent form if necessary. This feature allows VB6 developers to select an MDI child form as the application’s startup form. Under VB.NET you must ensure that the MDI parent form is already visible before trying to show an MDI child form.

The Upgrade Wizard produces code that is syntactically correct but that may raise a runtime error under VB.NET. VB Migration Partner takes care of this detail and correctly converts MDI applications.

StartUpPosition property

This property has been renamed StartPosition under .NET. The enumerated values that you can assign to this properties have different values.

TextWidth and TextHeight methods

These methods aren’t supported by VB.NET. Instead, you should use the MeasureString method of the System.Drawing.Graphics object.

VB Migration Partner fully supports these methods and accounts for the current ScaleMode.

ValidateControls method

The VB6’s ValidateControls method doesn’t return any value, but raises Error 380 if any control fails validation. Under VB.NET this method has been replaced by the Validate function, which returns False if validation fails (but never raises any error).

Visible property

VB.NET supports this property, which works as in VB6, except that it is ignored if it assigned the True value and the form is the application’s startup form. Under VB.NET the startup form can be made visible only by means of the Application.Run method.

VB Migration Partner fully supports the VB6 behavior for the Visible property.

Follow Francesco Balena on VB6 migration’s group on


Read Microsoft Corp’s official case study of a VB6 conversion using VB Migration Partner.

Code Architects and its partners offers remote and onsite migration services.

More details

Subscribe to our free newsletter for useful VB6 migration tips and techniques.


To learn more about your VB6 applications, run VB6 Analyzer on your source code and send us the generated text file. You will receive a detailed report about your VB6 applications and how VB Migration Partner can help you to quickly and effectively migrate it to .NET.

Get free advice

A fully-working, time-limited Trial Edition of VB Migration Partner allows you to test it against your actual code

Get the Trial

The price of VB Migration Partner depends on the size of the VB6 application, the type of license, and other factors

Request a quote

Migrating a VB6 application in 10 easy steps

Comparing VB Migration Partner with Upgrade Wizard

Migration tools: Feature Comparison Table

All whitepapers