Manage Code Complexity
Patterns are architectural strategies that describe solutions for known kinds of problems. This article discussed the State pattern, which is a behavior pattern. The State behavior pattern supports dynamic reclassification, which is changing the behavior of a context (like a form) at runtime.
To implement the State pattern in VB6, define an interface that defines all of the properties and behaviors of your context. Then implement a specific instance of the state interface for each behavior that the context—a form in this example—supports. Add more state classes to support additional states. Each state's code is independent of the others.
Using state objects is referred to as behavior delegation. Behavior delegation can be used proactively to prevent spaghetti code or reactively if code grows beyond a manageable level of complexity.