Upgrade
Wizard
The paramarray parameter in the process indicates an upgrade warning. For example, the following code:
Function myfunction (paramarray P () as variant)
'...
End Function
After the upgrade, it will be changed:
'Upgrade_warning: paramarray P was changed from byref to byval
Function myfunction (byval paramarray P () as object)
'...
End Function
Declared as any parameter
Visual
The parameter of the local API of basic 6.0 can be declared as any, so that any data type can be transferred to the local API call. Using this method, you can call APIs that support two or more data types.
Visual Basic. net
An overloaded declare statement can be defined to allow calls of local APIs with two or more data types. For example, the following declare statement:
Private declare function getprivateprofilestring _
Lib "Kernel32" alias "getprivateprofilestringa "(_
Byval lpapplicationname as string ,_
Byval lpkeyname as any ,_
Byval lpdefault as string ,_
Byval lpreturnedstring as string ,_
Byval nsize as long ,_
Byval lpfilename as string) as long
It can be replaced by two declare versions. One accepts long and the other accepts strings.
Overloads private declare function getprivateprofilestringkey _
Lib "Kernel32" alias "getprivateprofilestringa "(_
Byval lpapplicationname as string ,_
Byval lpkeyname as string ,_
Byval lpdefault as string ,_
Byval lpreturnedstring as string ,_
Byval nsize as long ,_
Byval lpfilename as string) as long
Overloads private declare function getprivateprofilestringnullkey _
Lib "Kernel32" alias "getprivateprofilestringa "(_
Byval lpapplicationname as string ,_
Byval lpkeyname as long ,_
Byval lpdefault as string ,_
Byval lpreturnedstring as string ,_
Byval nsize as long ,_
Byval lpfilename as string) as long
This improves the type security and reduces the small issues that cause program failures. This situation exists because the compiler does not allow calling APIS by explicitly defining data types.
Upgrade
Wizard
Use the declare statement of the as any parameter to mark the upgrade warning.
Implements
Visual
The basic 6.0 implements statement specifies the interface or class implemented in the class module that appears.
Visual Basic. net
There are two essential differences between implements in Visual Basic. NET and implements in Visual Basic 6.0:
Classes cannot be specified in implements statements.
Each implementation method requires that the implements clause be used at the end of the method declaration statement. This clause specifies the interface method it implements.
The implements clause is required for each method that implements the interface method, which improves code readability. This advantage is obvious when you read the code that uses methods to implement the interface method.
Upgrade
Wizard
If Class A implements Class B, Class B declares the interface, and Class A changes to the interface that implements Class B:
Interface _ B
Function myfunction () as string
End Interface
Class
Implements _ B
Function B _myfunction () as string implements _ B. myfunction
End Function
End Class
Attribute
Visual
In Visual Basic 6.0, get, let, and set attribute functions of specific attributes can be declared using different levels of access options. For example, the property get function can be declared as public, and the property let can be declared as friend.
Visual Basic. net
The get and set functions of the attribute must have the same access options. In this way, Visual Basic. Net can be operated collaboratively with other. NET languages.
Upgrade
Wizard
If the access options are of different levels, the new attribute is public.
Default Properties
Visual
Basic 6.0 any member can be marked as the default value of the class.
Visual Basic. net
Only attributes that accept parameters can be marked as default values. This situation is common for the parameter attributes that will become indexes in the set.
This makes the code more readable, because references to object variables without members usually point to the object itself, rather than to the objects in the context and the default attributes in other contexts. For example, the call display (textbox1) statement may pass the text box instance to the display function or the content of the text box.
In addition, deleting this ambiguity avoids the use of separate statements to execute the reference assignment. Assigning x = y always means assigning the content of variable Y to variable X, instead of assigning the default attribute of the object referenced by Y to the default attribute of the object referenced by X.
Upgrade
Wizard
Resolve the default attributes as much as possible. When the object cannot be resolved (delayed binding object), an error comment will be added.
Enumeration
Visual
Basic 6.0 enumeration constants can be referenced infinitely.
Visual Basic. net
If an import is added for an enumeration at the file or project level, the enumeration constant can be referenced infinitely.
In this way, it can be consistent with the class, structure, and interface. In the class, structure, and interface, you can assign a common name to the member without worrying about conflicts with other members. For example, color enumeration and fruit enumeration can both contain constants named orange. In Visual Basic 6.0, the rule is to add a prefix to an enumeration constant to keep each constant unique. This makes constant names cumbersome, such as mscolororange and msfruitorange.
Upgrade
Wizard
The reference to enumeration will be fully qualified.
While
Visual
The basic 6.0 while statement ends with the wend statement.
Visual Basic. net
To be consistent with other block structures, the end sentence of while is changed to end while. This improves the consistency and readability of the language.
Upgrade
Wizard
Change the wend statement to end while.
On... goto and on... gosub
Visual
Basic 6.0 based on the expression value, The on expression goto destinationlist and on expression gosub destinationlist statements direct the program to one of several specified rows in the target list.
Visual Basic. net
On... goto and on... gosub are unstructured programming structures. Their use makes the program more difficult to read and understand. Select case provides a more structured and flexible way to execute multiple branches.
Note: On Error goto is still supported.
Upgrade
Wizard
Example:
On myvariant goto 100,200,300
An upgrade error will be marked:
'Upgrade_issue on myvariable goto was not upgraded
On myvariant goto 100,200,300
You should rewrite the code to avoid using such statements, such:
On X go 100,200,300
It can be rewritten:
Select case x
Case 1: 'insert 100th rows of code
Case 2: 'insert 200th rows of code
Case 3: 'insert 300th rows of code
End select
Gosub... return
Visual
Basic 6.0 gosub line... return statement in the process to branch to the child routine, and then return from the child routine.
Visual Basic. net
Gosub... return is a non-structured programming structure. Its use makes the program more difficult to read and understand. A more structured alternative is to create an independent process that can be called.
Upgrade
Wizard
Similar to on... goto, these statements mark upgrade errors.
Lset
Visual
Basic 6.0 lset fills the string with spaces to make it the specified length, or copies the User-Defined type variable to another user-defined type variable.
Visual Basic. net
The lset statement is not supported. Lset is not safe for the type, so it may cause errors during runtime. In addition, because it is not secure for the type, the execution time code must be completely reliable. After the lset statement is deleted, one structure cannot be copied to another structure. However, you can modify the Visual Basic. Net code and use rtlcopymemory to achieve the same effect.
Upgrade
Wizard
Statement:
Lset a1 = a2
An upgrade error is marked
'Upgrade_issue: lset cannot assign a UDT from one type to another
Lset a1 = a2
Varptr, strptr, and objptr
Visual
Basic 6.0 varptr, strptr, and objptr return the address of the variable in integer form, and then pass the address to the API function using the address (such as rtlcopymemory ). Varptr returns the variable address, strptr returns the string address, and objptr returns the object address. None of these functions are recorded in the document.
Visual Basic. net
The address of a data item can be retrieved, but the retrieval must be performed only by calling CLR. This is because CLR can normally move projects freely in the memory, so it is necessary to let CLR know when to use the address and cannot move the project. The following example retrieves the object address:
Dim mygchandle as gchandle = gchandle. alloc (O, gchandletype. Pinned)
Dim address as integer = CINT (mygchandle. addrofpinnedobject ())
'...
Mygchandle. Free () 'allows moving object instances again
Allowing Mobile Data projects during runtime can improve runtime Performance