VB Migration Partner

KNOWLEDGE BASE - Forms and controls


Previous | Index | Next 

[PRB] Forms with same name as one of their controls can’t be opened in Visual Studio designer

In VB6 you can create a form that contains a control whose name matches the form’s name. VB Migration Partner converts these forms and the resulting application works as expected, but Visual Studio crashes if you attempt to open the form in the designer.

As a matter of fact, VB.NET lets you create a form that contains a control with same name only if you directly edit the *.Designer.vb file; if you attempt to create such a form in Visual Studio’s designer, an “Invalid Value” error message appears when you assign the duplicate name to either the form or the control.

The obvious workaround for this problem is to rename either the form or the control in the VB6 application, before attempting the migration. You can do either manually, from inside the Visual Basic 6 IDE, or by means of a PreProcess pragma. For example, suppose that you have both a form and a command button named “Save”, and you want to rename the latter into “btnSave”. Here’s the pragma you need:

        '## PreProcess "(?<!'##.+?)(?<!\"")(?<!VB\.Form\s+)(?<!New\s+)Save(?=_|\b)",
            "btnSave", False, True

The various (?<!...) portions  of the regular expression are needed to mistakenly rename the form’s name or occurrences of the “Save” string; the fourth argument is True because this pragma must affect also the hidden portion of the .frm file.

Previous | Index | Next 




Follow Francesco Balena on VB6 migration’s group on

LinkedIn





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.

newsletter



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