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

One nuance to consider when migrating Visual Basic 6.0 software is the 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

Visual Basic for applications is manipulating 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

Another factor to consider when converting Visual Basic 6 software are so-called 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

Microsoft VB does facilitate form chaining, a concept where any VB6 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

Microsoft Visual Studio 6.0 does provide 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. 

If you don’t have the expertise to handle such nuances, you can go for outsourced .NET development services.

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.

But despite the rather slight difference, modern .NET development solutions still provide greater capabilities.

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, in particular VB6 IDE Windows 11, 10, 8/8.1, and 7
  • Data access
  • Control architecture, behavior, customization, and adaptation
  • Testing, validation, performance optimization, and more
Visual Basic .NET migration by a Microsoft Gold Certified Partner
Empowering leaders on their digitization journey since 2007
READ MORE

How we can help

Abto Software, .NET software development company, is assisting business leaders 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.

Abto Software, .NET application development company, is there 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!

FAQ

How much does VB6 code to .NET migration cost?

The cost of your future project will depend on factors that include:

  • Team size and expertise
  • Technology stack
  • Project size and complexity
  • Chosen approach
  • Software customization
  • Further enhancements, and many other factors

Abto Software has the specialized expertise for transitioning mission-critical applications without disruption. Our engineers can handle every stage from initial business consulting to planning, assessment, preparation, and meticulous VB6 to .NET migration documentation management.

How long does VB6 code to .NET migration take?

The timeline of your prospective project also depends on various internal and external factors:

  • Codebase quality and understanding
  • Stakeholder involvement
  • Legacy dependencies
  • Third-party integrations, and more

Abto Software has the required expertise to deliver desired results in the shortest times without disruption. Our teams can handle the most complex challenges, for example VB6 to .NET migration compatibility issues, thereby minimizing potential delays.

What are the common errors during VB6 to .NET migration?

Code migration might cause dependency conflicts, deprecated functions and libraries, and many other issues.

To eliminate potential problems after handling code conversion, you should contract professional IT providers. In particular, software engineers with expertise in debugging VB6 to .NET migration issues efficiently.

Do you need post-migration support for VB6 to .NET migration?

Code migration, even when done successfully, can cause various challenges even after software deployment: memory leaks, management issues, runtime errors, database problems, and others.

To minimize the struggle and potential regulatory non-compliance, you should consider getting IT assistance. Contract skilled software engineers to handle testing after VB6 to .NET migration, and provide other services, including support and maintenance.

Contact us

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