Index | Next 

Declare

VB.NET fully supports the Declare keyword, except the ability to define “As Any” parameters. When converting a VB6 application you should replace such parameters with a definite data type; if callers pass different data types to the Declare – for example, a Long and a String – you should provide different overloads of the Declare statement, so that no “As Any” parameters are necessary.

Another problem with Declare statements is that VB.NET doesn’t support 32-bit integers used as callback addresses, as it happens with a few Windows API methods such as EnumFonts or EnumWindows. In this case you must declare a Delegate class with opportune syntax and change the parameter type so that it uses the delegate.

Finally, a minor problem you might face is that VB6 allows Declare statements containing two or more parameters with same name, but they are illegal under VB.NET.

VB Migration Partner handles these problems automatically: it generates all the necessary overloads for the Declare, defines one delegate class for each callback parameters, and adjusts parameter names if any duplicate exists.

 

Index | Next