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

A GDI+ Introduction for Visual Basic 6 Programmers

Problems With The Converted Program

By Dan Mabbutt, About.com

A lot of If-Then-Else "flag" testing was required to do this - usually a bad sign because it's not the "object oriented" way. The button and label controls that are used in the program are actually positioned on top of each other and the Visible property is used to determine when they are active. When a button is visible, it receives the click event but when a radio button is visible in the same space, it receives the click event instead. This is a complicated way to do it, but we're almost forced into it with the "hybrid" architecture that we're still trying to use.

Exactly the same event code is used for both radio buttons as well. See the Handles
part of the Sub statement below.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Private Sub optEndGame_CheckedChanged( _
   ByVal eventSender As System.Object, _
   ByVal eventArgs As System.EventArgs) _
   Handles optYes.CheckedChanged, optNo.CheckedChanged

   If optYes.Checked = True Then
      ' clean up graphics object
      g.Dispose()
      End
   End If

   If StartedFlag <> EndGame Then
      grpYesNo.Visible = False
      lblMessage.Visible = False
      cmdNewGame.Visible = True
   End If

Certainly, a cleaner Tic Tac Toe program can be written using fully object oriented coding. We see that in the next article!

Explore Visual Basic

More from About.com

  1. Home
  2. Computing & Technology
  3. Visual Basic
  4. Using VB.NET
  5. A GDI+ Introduction for Visual Basic 6 Programmers

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

All rights reserved.