Thomas Alva Edison's light bulb VBInfoZine Home
   An ordinary VB developer shares his own successes and failures
   FREE to registered subscribers.  

Use 'Select Case' selectively - Addendum

Here is the source code and a few notes accompanying the original article.

The real software discussed in the article uses a voting engine embedded within the Philips' Central Control Unit (CCU), which is wrapped by the Voting class. Because you probably don't have a CCU at your disposal, the first thing would be to emulate the original voting engine's functionality.

The Voting class does its job by employing a simplified state design pattern (once again ;-)) and a simplified version of the original Voting class' interface, excluding things like voting timers, voting round numbering, delegate database and voting results handling...all the stuff not directly related to the domain of state machines.

The user interface code consists of two forms – the FVotingOld form and the FVotingNew form.

The FVotingOld form uses the classic Select Case approach for handling the various voting states.

The FVotingNew form uses the 'state' approach discussed in the original article.

Both forms use the Voting class, whose instance is passed to the forms' constructors.

I encourage you to experiment a bit with the project and step through the 'old' and 'new' code to grasp the differences.

Enjoy!

(c) Palo Mraz, Sunday, August 31, 2003


Riko helping me with the code:-) 

 ©2003-2007 Palo Mraz. All Rights Reserved.   See my 'new browser window' policy