"The code is exactly
how I would like to write code and the algorithms used are very
efficient and well-documented."
Van T. Dinh, Microsoft MVP
|
|
Class: CValidateControl
Class that provides the ability to perform validation on controls in their LostFocus events Many people assume that it is easy to perform validation for VB controls in the LostFocus event. Actually this can be quite a problem.
Consider the scenario where you have two text boxes, Text1 and Text2. Both have code in their LostFocus events which checks to see that valid data was entered.
When the user tabs out of Text1, the LostFocus event fires, so the programmer displays a message box and attempts to set the focus back onto Text1. However before focus can be set to Text1, Text2 will receive a GotFocus event, and a LostFocus event. Unless the value in Text2 is already correct, the validation code in Text2 will fire, and the user will be stuck in an endless loop.
This class keeps a state variable which tracks whether a validation test is currently being performed. If a validation routine for Text1 is being performed, Text2 will NOT fire its validation messages, even if the validation for Text2 fails.
|
Procedure Name
|
Type
|
Description
|
|
(Declarations)
|
Declarations
|
Declarations and private variables for the CValidateControl class
|
|
Validate
|
Method
|
Check truth value of validation test and handle focus events to avoid deadlock LostFocus code.
This function is normally called in the LostFocus event of controls which you wish to modify.
|
Overview of Total Visual SourceBook
The source code in Total Visual
SourceBook includes modules and classes for Microsoft Access, Visual
Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily
add this professionally written, tested, and documented royalty-free code
into your applications to simplify your application development efforts.
Additional Resources
|
|