VB6 vs .NET controls, a comparison

VB6 vs .NET controls, a comparison

This post is a quick overview of an Abto Software blog article.

VB6 to .NET migration can get quite complex, with differences in properties, control behavior, layout, styling, and key operating mechanisms.

When comparing VB6 and .NET technology, the change in paradigms and established architectural foundations is significant, typically necessitating specialized expertise for performing extensive refactoring and adjustments. What’s more, VB6 controls might rely on already outdated technologies without direct .NET counterparts, naturally requiring creative alternatives to achieve desired functionality.

This brief guide highlights the important differences between VB6 and .NET technologies to know when moving towards modernization.

VB6 vs .NET controls, an overview

Align property

In Visual Basic 6, several controls (more specifically, Data, Frame, Label, PictureBox, CommandButton, TextBox) come with the so-called Align property, which enables automatic alignment of the form’s border with controls. In contrast, in the .NET framework, this feature is accomplished by the Dock property on controls within the System.Windows.Forms namespace.

Color values

In Visual Basic 6, color properties including ForeColor and BackColor are manipulated by using 32-bit integers. In the .NET framework, color values are represented by the System.Drawing.Color type.

After completed VB6 to .NET migration, color settings, their source and destination, are becoming color values. But still, there are some situations where converting 32-bit integers into so-called color values is essential.

Control arrays

Talking VB6, control arrays are facilitating the creation of controls at runtime and centralize event handling. However, the .NET framework doesn’t support control arrays, necessitating replacement with equivalents.

Data binding

VB6 and .NET support data binding, but differ in mechanisms:

  • VB6 supports data binding to various data sources, and allows further refinement by using StdDataFormat object and its Parse and Format events

  • .NET supports data binding no matter the object, as the actual capabilities are offered by the System.Windows.Forms.Binding object

To perform VB6 to .NET migration, software developers must know the differences in the core mechanisms. Such projects might require specific expertise in refactoring and further data integration.

Default form instances

VB6 and .NET both support default form instances, so there’s no requirement to instantiate form objects –forms are being referenced by using a variable named after the forms.

Font property (assignments)

VB6 allows setting default font instances to Nothing or a new instance.

Form chaining

In VB6, engineers enjoy form chaining, which means that forms, even the startup form, can unload and load other forms – for example, that can be implemented to present splash screens.

In .NET, this mechanism is supported for forms that are not designated as the startup form – talking about splash screens, this option can be only enabled in the Application tab of the My Project property page.

Drag-and-drop features

In VB6, engineers have two options:

  1. The “classic” VB3-style drag-and-drop for dragging and dropping items within VB applications

  2. The modern-day OLE drag-and-drop, first introduced in the VB5 version, for dragging and dropping items within Windows applications

In .NET, a unique programming model is provided to handle this functionality.

hWnd property

Talking specifically hWnd property, the feature is similar to the Handle property in the .NET framework, however, the Handle property does require additional conversion.

Left, Top, Height, and Width properties

VB6 determines the placement and dimensions of controls by applying Left, Top, Height, and Width properties. .NET does also support such properties, but the form designer still expects these values to be further specified.

Scale/ScaleX/ScaleY methods

In .NET, Scale/ScaleX/ScaleY methods aren’t supported – control size and position are expressed in pixels.

ScaleLeft, ScaleTop, ScaleHeight, and ScaleWidth properties

In .NET, such properties aren’t supported – as mentioned, control size and position are expressed in pixels.

ToolTipText property

  • VB6 controls expose the ToolTipText property

  • .NET controls do not expose the ToolTipText property, which means software developers are required to manually add an extender control and just then use the property

Validate event

In the .NET framework, the so-called Validate event was replaced by the Validating and Validated events. Handling migration, the initial event handler is to be replaced with the .NET Validating event handler.

Successful migration: why expertise does matter

VB6 controls are converted into equivalent .NET controls commonly involving substantive re-implementation. That presents multiple bottlenecks in terms of functionality, reputational and financial losses, and even regulatory non-compliance.

The conversion of legacy VB6 code to functional .NET code, not limited to but also including handling controls, requires proficiency in several key areas:

  • VB6 and .NET environments

  • Data access

  • Control architecture, behavior, customization, and adaptation

  • Testing, validation, performance optimization, and more

Summing up

Abto Software has the required expertise to help business leaders successfully handle application migration. Our engineers can cover every stage from assessment to finalization, ensuring needed application functionality for thriving business performance.

Don’t hesitate to approach VB6 migration and eliminate existing constrains by moving towards transformation.

Our services:

  • Business analysis and consulting

  • Project setup and kick-off

  • Code migration

  • Code finalization

  • Acceptance testing and improvement

  • Quality assurance and deployment

Your benefits:

  • Higher performance and efficiency

  • Expanded functionality and scalability

  • Improved security through updates and patches

  • Enhanced compatibility across platforms and devices

  • Long-term support and maintenance

  • Cloud compatibility