Visual Basic is an event-driven programming system, and design models which acknowledge this can add much-needed rigour to the development cycle. The Finite State Machine
is an event-based model that fits well into the Visual Basic scheme of doing things, and we'll look at it in detail here. This series of articles shows not only how to design parts of a Visual Basic program with FSMs, but how to carry the design through to implementation.
This material was adapted from Chapter 14 of Advanced Visual Basic 5, which in turn was based on an article I wrote for the now defunct VB User magazine.
The chapter also made it into the Second Edition (as Chapter 13) but it wasn't updated for VB6. I've taken the opportunity to update it now, so this chapter closes with an all-new FSM implementation for VB6.
Source code is available here.
Introduction Modelling Design with FSMs Implementing FSMs in VB
Adding an Event Queue Data-driven Code
Return of the Comment Stripper Into the Real World Better FSMs with Visual Basic 6 |