BYTEINSIGHT
GAPVelocity AI Studio helps you move from outdated tech stacks to the latest desktop, web, and cloud platforms—smarter, faster, and with less risk.
Choose a platform to see migration options:
GAPVelocity AI helps you move from outdated tech stacks to the latest desktop, web, and cloud platforms—smarter, faster, and with less risk.
Choose a platform to see migration options:
Our comprehensive approach to application modernization, from assessment to production deployment.
Transformation Services
Not Sure Where to Start?
As part of the VB6 AI Migrator’s advanced functionalities, the tool makes the converted code more .NET-like, while also improving aesthetic aspects.
Some of the enhancements are related to code simplifications. The following examples show some of these cases:
| Source pattern | Target .NET pattern |
| if <cond> then return true else return false | return <cond> |
| if <cond> then <var> = true else <var> = false | <var> = <cond> |
| if <cond> then <var> = false else <var> = true | <var> = !<cond> |
| <booleanexpression> compared to true or false | [!] <booleanexpression> |
| Operations simplifications like: (<exp> + 1) > 0 |
<exp> >= 0 |
| !(!<expression>) | <expression> |
| Arithmetic simplifications | Several simplifications like: (<expression> + 1) - 1 => <expression> |
| Err.Raise | throw new Exception() |
Other enhancements are related to library members that were previously converted to the .NET Visual Basic 6 Compatibility Library. The VB6 AI Migrator converts them to .NET Framework native libraries, as shown in the following table:
| Source pattern | Target .NET pattern |
| <timer_reference>.Interval compared to 0 patterns. | Patterns of <timer_reference>.Enabled |
| Dir(<path>, vbDirectory) compared to empty string. | [!] System.IO.Directory.Exists(<filename>) |
| vb.App.LogEvent | System.Diagnostics.EventLog.WriteEntry |
| VBA.FileSystem.Kill | System.IO.File.Delete |
| vba.FileSystem.FileCopy | System.IO.File.Copy |
| VBA.Strings.Format VBA.Strings.FormatNumber VBA.Strings.FormatPercent |
Different patterns of p.ToString(...) |
| VBA.DateTime.Date | Uses of System.DateTime.Now |
| VBA.DateTime.DateValue | Uses of System.DateTime.Parse |
| VBA.DateTime.DateAdd (<interval>,<num>,<date>) |
<date>.AddYears(<num>) <date>.AddMonths(<num>) <date>.AddDays(<num>) <date>.AddHours(<num>) <date>.AddMinutes(<num>) <date>.AddSeconds(<num>) |
| VBA.Information.IsEmpty(p) where “p” can be a: - numeric - boolean - date - string - object |
numeric -> p.Equals(0) boolean -> p.Equals(false) date -> p.Equals(DateTime.FromOADate(0)) string -> p.IsNullOrEmpty() object -> p.Equals(param,Nothing) |
| VBA.Strings.Split(...) | Various patterns of <string-object>.Split(…) |
| VBA.VbMsgBoxResult | Patterns of System.Windows.Forms.DialogResult |
| VBA.VbDayOfWeek | System.FirstDayOfWeek |
| VBA.Strings.Left VBA.Strings.Right VBA.Strings.Mid |
Uses of <str-object>.Substring(…) |
| VBA.Constants.<char-const> | Strings.Chr(<value>) / chr(13) |
| File IO operations | Converted using System.IO namespace |
The VB6 AI Migrator detects If-ElseIf blocks with all its conditions, comparing the same expression against different values and converting them to a more natural Switch block.
When VB6 For loops iterate over collections and some arrays, VB6 AI Migrator upgrades the statement to .NET ForEach statements, applying the necessary transformations to the collection/array references inside the For body and the counter variables.
Counter variables that are no longer needed after the Foreach transformation are removed from the resulting code block.
Some classes in VB6 have two events that correspond to one unique event in the corresponding .NET class. In those cases, the bodies of the two events are merged to achieve the same behavior.
Some examples of these transformations are:
This rule allows adding the variable initialization value to its declaration:
Dim _myvar as MyType ... <Code which doesn’t reference _myvar> _myvar = InitValue
MyType _myvar = InitValue; ... <Code which doesn’t reference _myvar>
Besides the option of generating references to the .NET library elements by using their fully qualified names, the VB6 AI Migrator introduces an additional transformation stage that recognizes fully qualified names and simplifies them while automatically generating the necessary import / using causes.
This new feature makes the converted code look much better providing an improved readability and maintainability.