Using the VB Snippet Upgrade Add-In

Using the VB Snippet Upgrade Add-In

What is a snippet? A snippet is a fragment of code, such as a procedure or even just two or three lines of code. A Visual Basic 6 snippet is a fragment of Visual Basic 6 code. It may be sample code that you received by e-mail, or it might be a function you use all the time. The VB Snippet Upgrade add-in is designed for upgrading snippets. It is useful when you want to upgrade only a few lines of code, not an entire project. To use it, you must have a Code Editor window open in Visual Basic .NET. Choose VB Snippet Upgrade from the Tools menu. The VB Snippet Upgrade window opens, as shown in Figure 5-15.

Figure 5-15

The VB Snippet Upgrade add-in.

Simply type or paste Visual Basic 6 snippet code into this window, and click the Upgrade button. Let s try upgrading a simple example. Type the following into the window:

Dim x As Integer Debug.Print x

Now click the Upgrade button. The snippet is upgraded and inserted into the Code Editor at the current insertion point:

Dim x As Short System.Diagnostics.Debug.WriteLine(x)

The VB Snippet Upgrade add-in is a great way to familiarize yourself with how code upgrades from Visual Basic 6 to Visual Basic .NET. The add-in can upgrade several lines of code, a function, or even a whole module. The only limitation is that the snippet can t refer to functions or objects that are not included as part of the snippet the VB Snippet Upgrade add-in needs to examine all of the objects and functions you use in that snippet. If they are defined elsewhere, the add-in won t know how to interpret them. You can add references to the snippet, however. A list box on the References tab allows you to add or remove COM libraries that your snippet references. Any libraries you add here are also added to your Visual Basic .NET project.

Getting Updates

As this book went to press, the VB Snippet Upgrade add-in was still in development, and Microsoft had not yet decided whether it would be ready to ship with Visual Basic .NET or be made available later as a download. If it is not installed with Visual Basic .NET, you will be able to get it from the Visual Basic Web site, http://msdn.microsoft.com/vbasic/. From time to time this Web site is updated with new versions of the Upgrade Wizard, the VB Snippet Upgrade add-in, and other resources for upgrading. These updates may contain bug fixes, whitepapers, or new upgrade capabilities.



Upgrading Microsoft Visual Basic 6.0to Microsoft Visual Basic  .NET
Upgrading Microsoft Visual Basic 6.0 to Microsoft Visual Basic .NET w/accompanying CD-ROM
ISBN: 073561587X
EAN: 2147483647
Year: 2001
Pages: 179

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net