|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.|
Upgrade Visual Basic 6 Code Dialog Box
Use the Upgrade Visual Basic 6 Code dialog box to upgrade Visual Basic 6.0 code to Visual Basic 2005 by typing code into the Code window or pasting code from the Visual Basic 6.0 Code Editor. When you click the Upgrade button, the upgraded code is inserted into the Visual Basic 2005 Code Editor at the cursor location.
In addition, COM references required by the Visual Basic 6.0 code can be added to the References tab; these are added to the references in your Visual Basic 2005 project.
To access the Upgrade Visual Basic 6 Code dialog box, choose Upgrade Visual Basic 6 Code from the Tools menu.
The Upgrade Visual Basic 6 Code command is only available when working in the Code Editor.
User Interface Element List
Visual Basic 6.0 code can be typed into the code window or pasted from the Code Editor. Code is retained between uses so that you can further modify it.
Displays COM references required by your Visual Basic 6.0 code.
- Reference Name
Displays the friendly name of the COM component. Only references that are checked will be added to the Visual Basic 2005 project.
Displays the version number (major and minor) of the COM component.
Displays the file path and file name for the COM component.
- Add Reference
Displays the Add Reference dialog box that contains a list of available COM components.
Upgrades any code entered into the code window and inserts it in the Visual Basic 2005 Code Editor; also adds any checked references in the References list to the Visual Basic 2005 project.
Tips for Using the Upgrade Visual Basic 6 Code Dialog Box
The Upgrade Visual Basic 6 Code dialog box cannot successfully convert all code. To maximize your use of this tool:
Make your code easier to upgrade by following the recommendations in. How your Visual Basic 6.0 code is written can affect how it is upgraded.
Test the code in Visual Basic 6.0 before attempting the upgrade. If the code does not run in Visual Basic 6.0, it will not run in Visual Basic 2005.
Event signatures in Visual Basic 2005 are different than their Visual Basic 6.0 counterparts. When entering code for form or control event procedures, first add the procedure declaration in Visual Basic 2005 and then upgrade only the body of the procedure.
The Upgrade Visual Basic 6 Code dialog box is designed to upgrade small sections of code. The code typed into the dialog box determines the context for the upgrade.
For example, the statement L.Caption = "MyCaption" would not be translated because the tool cannot determine the type for "L" to resolve the property Caption. Inserting a declaration for L (such as Dim L As Label) prior to the statement results in a successful upgrade.
Check that the syntax is correct for your Visual Basic 6.0 code, as incorrect syntax can cause an Untranslated statement in WrapperSub error.
For best performance, upgrade code in modules rather than in Form modules. If you need to upgrade a form, use the Upgrade Wizard.
If you paste code that contains Unicode characters, a dialog will appear asking if you want to remove them. If you choose OK, the code will be parsed and any Unicode characters will be removed.