Resources

VB6 vs VB.NET controls - CheckBox and OptionButton controls


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.





CheckBox and OptionButton controls

Alignment property

The VB6 Alignment property is missing in VB.NET and is replaced by the CheckAlign and TextAlign properties.



Appearance property

The Appearance property has been renamed as FlatStyle.



Click event

The Click event is supported under VB.NET; however this event doesn’t fire when the control’s Value is changed via code. Also, it is advisable not to use the MouseClick event, because such an event doesn’t fire if the control’s value is changed via the keyboard. The most reliable way to replicate the original VB6 behavior is using the CheckStateChange event.

VB Migration Partner correctly handles all these differences. Converted VB.NET code works exactly as in the original VB6 program.



Picture and Style properties

The VB6 Picture property maps to the VB.NET Image and Appearance properties, but the Style property has no VB.NET counterpart. (In VB6 the Picture property is used only if Style=1-vbButtonGraphical.) Therefore, you should assign the .NET Image property only if you really mean to display an image.

In addition to displaying an image, the VB6 Style property affects the position of the control’s caption: in standard buttons the caption is centered vertically, whereas in graphical controls it is near to the bottom border. You can reach the same effect by assigning the VB.NET TextAlign property.

VB Migration Partner fully supports all the possible combinations of these two properties.



TabStop behavior (OptionButton only)

VB6 and VB.NET differ in how a radio button is given the focus when the end users presses the Tab key. Under VB6, when the end user tabs into a group of radio button, the button whose Value is True receives the focus. Conversely, under VB.NET the radio button with the lowest value of the TabIndex property receives the focus, regardless of whether it is checked or not.

VB Migration Partner accounts for this difference and correctly mimics the VB6 behavior.



Value property

This property isn’t supported and maps to the Checked property.

In addition, there is a minor difference in what happens when you set the property to False in a radio button that is currently checked. In a VB6 OptionButton control, setting this property to False fires no Click events; in a VB.NET RadioButton control this assignment causes a Click event. (Note that you typically set the Value property to False when you need to display a group of unchecked buttons.)

To fully mimic the VB6 behavior, VB Migration Partner provides a ResetValue method, which changes the value of the Value property without firing any event:

        optChoice.ResetValue(False)






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