It Is Still Visual Basic

It Is Still Visual Basic

Despite the changes, programmers will still recognize the Visual Basic they know and love. Let s now look at what changes you will expect to see moving to Visual Basic .NET.

Expect Subtle Differences

Visual Basic .NET has been rebuilt for the .NET platform. What does this statement mean? It means that the product has been rewritten from the ground up. One of the side effects of rewriting Visual Basic is that any similarities with previous versions of the language had to be added intentionally you don t get them for free, as you do when you simply add new features to an existing code base. A programming language is composed of a million subtle nuances: the behavior of the Format function, the order of events on a form, and the undocumented hacks that are possible, like subclassing a form s message loop. Some of these subtleties are not exactly the same in Visual Basic .NET, and after upgrading an application, you may find small differences in the way the application works.

A good example is the Currency data type. In Visual Basic 6, the Currency data type has 4 digits of precision. In Visual Basic .NET, the Currency data type is renamed Decimal and has 12 digits of precision. If you run the following line of code in Visual Basic 6:

MsgBox( CCur(10/3) )

it produces 3.3333. If you run the equivalent line of code in Visual Basic .NET,

MsgBox( CDec(10 / 3) )

the result is 3.333333333333. This is not a huge change, but it underlies a principle of upgrading: Visual Basic .NET is subtly different from Visual Basic 6, and therefore upgraded applications will be different from their Visual Basic 6 counterparts in subtle ways. In most cases you will not notice the difference, yet it s important to be aware of the changes and to test your applications thoroughly after upgrading them. Chapter 2 examines the differences between languages in greater depth. For now, let s turn our attention to upgrading.

The Decision to Break Compatibility

When did Microsoft decide to break compatibility with Visual Basic 6? It was actually in early December 1999, during the development of Visual Basic .NET. Until that time, Visual Basic .NET was being developed to support the notion of Visual Basic 6 sourced projects that allowed you to edit and compile Visual Basic 6 projects in Visual Basic .NET. These projects would have a compatibility switch turned on, meaning that the language would be backward compatible with Visual Basic 6 and would even have access to the old Visual Basic 6 forms package.

By the end of 1999, it was obvious that this strategy wasn t working. Little differences were slipping through: The old forms package could not be fully integrated into .NET, and the Visual Basic 6 sourced projects could not use some of the new features of the .NET platform. At that point Microsoft made the decision to break compatibility and instead concentrate on ensuring that people could upgrade their projects from Visual Basic 6 to Visual Basic .NET.

Plan for a 95 Percent Automated Upgrade

The effect of the changes and subtle differences in Visual Basic .NET is that, unlike previous versions of Visual Basic, most real-world projects cannot be upgraded 100 percent automatically. To understand why, consider that for a 100 percent upgrade there has to be a one-to-one correlation between every element of Visual Basic 6 and a corresponding element in Visual Basic .NET. Unfortunately, this correlation does not exist. The upgrade process is closer to 95 percent, meaning that the Visual Basic .NET Upgrade Wizard upgrades 95 percent of your application, and you modify 5 percent of the application to get it working. What does 5 percent mean? If it took you 100 days to write the original Visual Basic 6 application, you might expect to take 5 days to upgrade it. This number is not set in stone some applications are easier to upgrade than others, and the experience of the person doing the upgrade is an important factor. To prepare yourself, make sure you familiarize yourself with Part IV. It discusses how to design your Visual Basic 6 applications to make the upgrade process much smoother.

Part III of this book is devoted to helping you learn how to make the 5 percent modifications, since this is the essential skill you ll need for upgrading. Once you ve gotten your application working, Visual Basic .NET has a bunch of exciting new features that you can add to your application straight away. Chapter 18 of this book discusses some common ways you can add value to your upgraded application. In fact, we encourage you to think of the upgrade as occurring in three steps:

  1. Use the Upgrade Wizard to bring your application into Visual Basic .NET.

  2. Make the modifications to get your application working.

  3. Start adding value with the great new features of Visual Basic .NET.



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