1. Home
  2. Computing & Technology
  3. Visual Basic
The VB.NET Upgrade Wizard
Programming the Win Lines
 Related Resources
• The VB 6 Version:
TicTacToe

• A GDI+ Introduction for Visual Basic 6 Programmers
• A GDI+ Introduction for Visual Basic 6 Programmers
• Source for Upgraded .NET Version
 


Programming the Win Lines

As a reminder, at this point, our program compiles and starts to run, but it immediately crashes because there are no linwin Label components. Recall that we deleted these because diagonal lines can't be created using labels -- the Upgrade Wizard's only trick to replace the old familiar VB 6 line component. The first thing to do is to delete the remnants of the linwin Label components placed in the program by the upgrade wizard.

Next, notice that at the bottom of the form in design mode, there are three interesting icons:

There are two new .NET innovations to talk about here.

First is the tooltip itself. This wasn't even a part of our original Tic Tac Toe program. The conversion wizard just threw it in for good measure. In VB 6, tooltips are part of individual controls. The result is that some controls have them -- some don't. VB.NET changes this and allows you to use a tooltip on any component in a form so long as the tooltip control has been added to the form. (This is part of the magic of the object oriented "inheritance" that is also new to VB.NET.) To use tooltips in VB.NET, the target control and tooltip message are passed to the tooltip as parameters. Since our program doesn't use tooltips, this can simply be deleted. (Or not -- it doesn't get in the way either.)

Second is the way controls that don't have a visible component on the form itself are displayed in VB.NET. Another example where you will see this is the Timer control that is in both VB 6 and VB.NET. These are now grouped together in a separate area below the form rather than being required to actually be on the form as in VB 6.

lblPlayGround and linWin have been added by the Upgrade Wizard and are there as a result of the very interesting Microsoft.VisualBasic.Compatibility class that the conversion wizard depends on. The "Control Array" is another common VB 6 technique that VB.NET doesn't support. (About Visual Basic has a whole series of articles showing you different ideas for coding something like the old VB 6 control arrays in VB.NET. Click Here.) There are two in our program, the win lines (linWin) and the array of labels that have either an X or an O in them (lblPlayGround). We have already concluded that we're going to have to replace the win lines by drawing directly to the form with GDI+ so we can simply delete that collection. Remember that the code in the Region "Windows Form Designer generated code" is adjusted automatically when you do this! The lblPlayGround collection works so we're going to simply leave it alone.

Next page > Finally, The Programming Begins! > Page 1, 2, 3, 4, 5, 6, 7, 8, 9

Explore Visual Basic

More from About.com

  1. Home
  2. Computing & Technology
  3. Visual Basic

©2008 About.com, a part of The New York Times Company.

All rights reserved.