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:
Our comprehensive approach to application modernization, from assessment to production deployment.
Transformation Services
Not Sure Where to Start?
Visual Basic 6 presents early, late and/or dynamic binding for objects and variables; these concepts refer to the time when that specific object or variable type is defined. As per Early Binding it can be said that an object is early bound when it is assigned to a variable declared to be of a specific object type.In contrast to this concept Late Binding is the linking of a routine or object at runtime based on the conditions at the moment. A common issue found by the VB6 AI Migrator is the inability to resolve default properties in late binding cases.
In a nutshell, VB6 is able to resolve during runtime the type of any variable, and if it is necessary, to expand the default property of that type in order to get the correct value to be used. In the following example you can see that the variable ‘o’ is an Object, which must have a default property; at runtime VB6 expands its corresponding default property and gets or sets the value.
The VB6 AI Migrator is able to solve the late binding conflicted default properties by means of a helper class called “DefaultPropHelper”
Private Sub Foo(ByVal o As Object) Dim v As Variant o = "Value for the Default Property" v = o End Sub
Public Sub Foo(ByVal o As Object) 'UPGRADE_WARNING: (1037) Couldn't resolve default property of object o. o = "Value for the Default Property" 'UPGRADE_WARNING: (1068) o of type Object is being forced to Scalar. Dim v As Object = o End Sub
Public Sub Foo(ByVal o As Object) DefaultPropHelper.SetDefaultProperty(o, "Value for the Default Property") Dim v As Object = DefaultPropHelper.GetDefaultProperty(o) End Sub
private void Foo( object o) { //UPGRADE_WARNING: (1037) Couldn't resolve default property of object o. o = " Value for the Default Property"; //UPGRADE_WARNING: (1068) o of type object is being forced to string. string v = o; }
private void Foo( object o) { DefaultPropHelper.SetDefaultProperty(ref o, "Value for the Default Property"); string v = DefaultPropHelper.GetDefaultProperty<string>(o); }