VB Migration Partner

KNOWLEDGE BASE - Forms and controls

Previous | Index | Next 

[PRB] Errors when re-opening modal, default forms that host an ActiveX control

Consider the following scenario:

  1. You have a form that hosts one or more ActiveX controls
  2. You display the form modally (e.g. Form1.Show 1)
  3. You access the form using the default instance rather then creating a fresh instance of the form.

In these circumstances, you can experience runtime errors when you close and then re-open the form.

The simplest workaround for this problem is using a fresh new form:

     ' old code
     Form1.Show vbModal
     ' new code
     Dim frm As New Form1
     frm.Show vbModal

You can even use a variable named after the form class to “shadow” the default form instance:

     Dim Form1 As New Form1
     Form1.Show vbModal

This latter solution can be easily implemented by means of a single InsertStatement pragma:

     '## InsertStatement Dim Form1 As New Form1
     Form1.Show vbModal

If you are forced to use the default form instance you must adopt a different workaround: you should set the AutoDisposeModalForm static property to False before showing the form and invoke the ResetVariables protected method after showing the form

     '## InsertStatement VB6Form.AutoDisposeModalForm = False
     Form1.Show vbModal
     '## InsertStatement MyBase.ResetVariables()
Previous | Index | Next 

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