VB6 vs .NET controls, a comparison

VB6 vs .NET controls, a comparison

VB6 and .NET controls can pose considerable challenges during migration, sensibly differing in properties, control behavior, layout, styling, and mechanisms.

Talking about VB6 and .NET technology, the paradigms and established architectural principles between the two fluctuate significantly, accordingly requiring extensive refactoring and adaptation of the existing codebase. Another thing, VB6 controls may also have dependencies on deprecated, obsolete technologies, which might not have .NET equivalents, potentially necessitating alternative solutions to ensure expected functionality.

In this short overview, we will shed light on the most important differences between those two to know.

VB6 vs .NET controls, a glimpse at the main disparities

Align property

Several controls in the VB6 language, including Data, Frame, Label, PictureBox, CommandButton, and TextBox, feature an Align property, which allows the control to be automatically attached to one of the form’s borders. In the .NET framework, this functionality is provided by the Dock property that’s available on controls in the System.Windows.Forms namespace.

Color values

VB6 assigns and manipulates color properties (most commonly, ForeColor, BackColor) by using 32-bit integers. .NET represents color values by means of the System.Drawing.Color type.

After successful VB6 to .NET migration, the source and destination of a color setting are becoming color values. But in certain scenarios, it may be necessary to convert 32-bit integers to become color values, in particular when sourcing colors from data files, or when colors are dynamically generated.

Control arrays

In the VB6 language, control arrays are used to develop new controls at runtime and centralize event handling. In the .NET framework, control arrays are not being supported, which means they must be replaced with native .NET code.

Data binding

VB6 and .NET support data binding, but the used mechanisms are different: 

  • 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

So, for VB6 to NET migration, software developers must consider the difference in the described mechanisms. That might mean refactoring code relying on the VB6-specific functionalities to align with the .NET approach, and, additionally, the to-be-used data sources and their further integration may require careful consideration during the entire process.

Default form instances

VB6 and .NET support so-called default form instances, which means that there’s no requirement to instantiate form objects, as forms are referenced by using a special global variable named after the forms.

To note: .NET does not support the references inside forms.

Font property (assignments)

VB6 allows setting default font instances to Nothing or a new instance, and, it’s worth mentioning, the latter is the same option as the former one.

To note: .NET allows only setting the default font instance to Nothing.

Form chaining

VB6 facilitates form chaining, a concept where any VB6 form, including the startup form, can unload and load another form – for instance, VB6 applications frequently implement form chaining to present splash screens.

.NET, on the contrary, only supports this mechanism for forms that are not designated as the startup form, which means, to implement splash screens, .NET applications enable the relevant option in the Application tab of the My Project property page.

Drag-and-drop features

VB6 provides the following drag-and-drop functionalities:

  1. The “classic” VB3-style drag-and-drop enables dragging and dropping items within VB applications
  2. The modern OLE drag-and-drop, first introduced in the VB5 version, allows dragging and dropping items within Windows applications; it utilizes common properties as OLEDragMode and OLEDropMode and methods like OLEDrag, as well as events, including OLEStartDrag, OLESetData, OLEDragOver, OLEDragDrop, OLECompleteDrag, and OLEGiveFeedback

.NET provides a unique programming model, which differs from both the “classic” and modern OLE models.

hWnd property

Talking about VB6 features, this property is corresponding to the Handle property in the .NET framework, however, the Handle property returns an IntPtr value, which requires software developers to convert it into integer type during migration. 

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 these properties, but the form designer still expects these values to be specified using Position and Size properties, which require Point and Size objects.

Scale/ScaleX/ScaleY methods

.NET supports control size and position exclusively expressed in pixels, as the Scale/ScaleX/ScaleY methods, which adjust control dimensions in the VB6 code based on a specified measurement unit, aren’t supported. This implies that during VB6 to .NET conversion, source code that utilizes mentioned methods for adjusting control dimensions is to be refactored.

ScaleLeft, ScaleTop, ScaleHeight, and ScaleWidth properties

.NET supports control size and position only expressed in pixels, as the specified properties aren’t supported. This means that for VB6 to NET conversion, any code that relies on these to adjust control size and position requires modification.

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 that it adds to all controls

Validate event

In the .NET framework, the so-called Validate event was replaced by the Validating and Validated events – talking practice, when converting a legacy VB6 application, the initial event handler is to be replaced with the .NET Validating event handler.

This section is based on concepts originally discussed in a VB Migration Partner’s whitepaper.

Successful migration: why expertise can make the difference

The conversion of existing VB6 controls into their .NET equivalents may involve substantive re-implementation, which presents serious challenges when approaching similar projects without possessing necessary expertise. If not approached correctly during migration, the disparities between controls may cause lacking functionality, burdened maintenance, 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
VB6 migration by a Microsoft Gold Certified Partner
Empowering leaders on their digitization journey since 2007

How we can help

Abto Software is assisting business leaders moving towards embracing innovation by handling VB6 migration. Our engineers cover everything from initial code assessment to successful VB6 migration and finalization, ensuring functionality and scalability, as well as elevated business performance.

Migrate VB6 to .NET to address and eliminate limited functionality, security vulnerabilities, compatibility issues, and insufficient business performance.

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

Migrate VB6 to NET by harnessing proven expertise!

Contact us

Tell your idea, request a quote or ask us a question