| You are here: | About>Computing & Technology>Visual Basic> Learn VB.NET> Visual Basic .NET 2008 Express - What's New With Visual Basic .NET Express |
![]() | Visual Basic |
Visual Basic .NET 2008 Express - What's New With Visual Basic .NET ExpressJan 12 2008 Part 4 of an About Visual Basic TutorialThis is a free tutorial to help beginning programmers get up to speed using Microsoft Visual Basic 2008 Express. To get the most from this tutorial, you might want to start at the beginning: Part 1 - A "From the Ground Up" Tutorial - An introduction to the course. Part 2 - Visual Basic Fundamentals - The basics of the VB Language and How To Find More Information Part 3 - About Programming - Software systems and the Systems Development Life Cycle. VB6 and the Bad Old Days Actually, those old days weren't that bad. They were only "bad" in comparison to what's possible today using .NET. But there's one thing for certain: VB6 was a whole different world. In fact, the main thing that is the same between VB6 and VB.NET is a language syntax similarity. I wrote an article about six of the "Top Five" Changes between VB6 and VB.NET. Why six? Well ... you'll just have to read the article to find out. If I had to sum up the difference between VB.NET and VB6 in just one phrase, it would be: VB.NET gives you access to everything. Here's just one example just to demonstrate the point. A VB.NET Event Subroutine In VB6, the call to a button event subroutine looks like this: Private Sub Command1_Click() In VB.NET, the same call has become: Private Sub Button1_Click( _ (The statement has been distributed over four lines with continuation characters so it will fit the web page display.) What is all that extra stuff? Here's a very brief explanation. For those of you who signed up for a beginner's tutorial and feel this is waaaay over your head, don't worry. Event subroutines will be covered in greater detail later. The goal right now is just to introduce the changes and improvements that have been made in .NET. This "extra stuff" in the .NET version is all information that was passed around behind the scenes in VB6. Back then, you could never access it in your program. (Welllll ... If you were willing to code a lot of API calls to Windows system software, many things became possible, but the more you did that, the closer you got to the pain and suffering of C++.) VB is supposed to make it easy and API calls make it possible but they don't make it easy. Sender is the software object which fired the event. In this case, it's System.Windows.Forms.Button. In VB6, 43 properties and 7 methods are available to your program for a Command component. In VB.NET, 94 properties, 51 methods, and 3 contained objects are yours to use in your code. VB6 doesn't pass any event arguments to a Command subroutine, but the object e, a System.EventArgs "type", is passed with every event in VB.NET and this gives you the ability to write code that wasn't possible in VB6. If you're curious about how I know that the object System.Windows.Forms.Button was responsible for firing this object, you can place a breakpoint on the first excutable statement in Button.Click event subroutine to suspend execution. Then run a test program. Pause your mouse over Sender and the tooltip explanation will tell you. The Handles clause is completely new in VB.NET and it's one of those things that was just not available before. Briefly, the Handles clause lets you specifically assign this subroutine to "handle" an event, like the click of a button. This can be a powerful feature as I demonstrated in my Calculator Program. In that program, just one subroutine handles all of the calculator keys (these are different Button components) by adding more Handles clauses to the same subroutine. VB.NET even gives you access to the system code where windows are drawn and controls are instantiated. (When a control is instantiated, a copy of the code for that control is created at runtime.) In VB.NET 2008, this system code is in a separate object, objectname.Designer.vb to keep it "out of your way" as you're writing your code, but it's still completely accessible. If you really have the need, you can access the IL code that the VB.NET compiler (and all other .NET languages) produce. Microsoft provides the ILDASM program just for that purpose. (ILDASM is described in my article, The .NET Framework Tools - Introduction and ILDASM.) There are two sides to all this new freedom and access, however. On the plus side is the fact that VB.NET is the equal of any other language now for whatever work you have to do. (I think that VB.NET is better because you can simply be more productive, but that's just my opinion.) On the minus side, this new freedom comes with new responsibilty and, yes, new complexity too. Because VB6 "protected" you from a system code, it was simplier and easier to use. VB.NET has a more difficult learning curve. On the next page, we look at the versions of VB.NET and the differences compared to VB Express. |
Las Vegas on a BudgetFind a BargainHotel DealsCheap EatsFree AttractionsEntertainment for Less |
All Topics | Email Article | | | ![]() |
| Advertising Info | News & Events | Work at About | SiteMap | Reprints | Help | Our Story | Be a Guide |
| User Agreement | Ethics Policy | Patent Info. | Privacy Policy | ©2008 About, Inc., A part of The New York Times Company. All rights reserved. |


