18.01.2013 Views

Visual Basic Upgrade Companion vs. Code Advisor - ArtinSoft

Visual Basic Upgrade Companion vs. Code Advisor - ArtinSoft

Visual Basic Upgrade Companion vs. Code Advisor - ArtinSoft

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

following objects are supported by VBUC by using helper classes implemented in .NET or by using<br />

special classes from the .NET Framework:<br />

• Printer Object<br />

• Printers Collection<br />

• Clipboard Object<br />

• Forms Collection<br />

Portions of code that use any other unsupported object will have to be rewritten in VB.NET.<br />

Declare with an early-bound data type<br />

Variables that were either not declared with a specific type or declared As Variant in VB6 are<br />

declared As Object in VB.NET. Since the actual type of a Variant (or late-bound) variable is not<br />

known until runtime, the <strong>Upgrade</strong> Wizard will not be able to determine which operations to apply to<br />

that variable, resulting in migration errors. For instance, since the type of the variable is not known at<br />

migration time, default properties will not be expanded, leading to issues and crashes when the<br />

migrated application is executed.<br />

The <strong>Visual</strong> <strong>Basic</strong> <strong>Upgrade</strong> <strong>Companion</strong> features an Artificial Intelligence-based type inference engine,<br />

which in most situations will be able to infer the type of a variable based on its usage in the source<br />

code, given that its runtime type remains consistent and that it interacts with literals and variables<br />

with known types. For example, the following code snippet<br />

Private Sub Sum()<br />

a = 1<br />

b = 2 + 3<br />

End Sub<br />

would be converted by VBUC to<br />

Private Sub Sum()<br />

Dim a As Byte = 1<br />

Dim b As Byte = 2 + 3<br />

End Sub<br />

Even when VBUC may not be able to infer the type of all the late-bound variables in the source code,<br />

it’s a good idea to let VBUC do as much work as it can do for you. Variables that still do not have a<br />

specific type after migration has taken place can be identified if you search for the following late<br />

binding <strong>Upgrade</strong> Warning<br />

'UPGRADE_WARNING: Couldn't resolve default property of object .<br />

Replace function with function<br />

In <strong>Visual</strong> <strong>Basic</strong> 6.0, text functions such as Mid, Trim and Right have both a “String” version and a<br />

“Variant” version, where the first one returns a String type and the latter returns a Variant type. String<br />

versions of these functions are preferable since they avoid late binding. These strongly-typed<br />

functions can be recognized because their names end with a dollar sign (“$”), which is also used in

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!