Using Visual Basic 6.0, the user will input 3 valid test scores, numeric values greater than or equal to 0. The programmer
will validate user input, will not allow non-numeric input. Call the text boxes txtScore1, txtScore2 and txtScore3.
Use the validate event.
Here is the code for the Average Test Scores program in a PDF file format which you may view with the free Adobe Acrobat Reader.
The link to the code example PDF file is above the picture of the form. This program is coded using events and
to the beginning Visual Basic 6.0 student. There is an example of the Validate event. In order for this event to work, you must
keep your controls on the form with a sequential TabIndex order so that you can tab from one text box to the next in the
proper sequence. Then, in order for a txtScore1_Validate(blnKeepFocus As Boolean) event to work, you must set the txtScore2.CausesValidation = True.
(Usually this is a Default setting, but not always). Each next object of what you want the validation event to work on, must have
its CausesValidation property set to True. For example, to use a Validate event for txtScore2, first set the txtScore3.CausesValidation = True. I do the setting (or checking to see if already set to true) of the CausesValidation properties at Design time. If you have
more questions about the Validation event, use the resources about Visual Basic in the MSDN library at microsoft.com. They have
very good resources about Visual Basic and a Visual Basic tutorial section as well. Use their search tools at the Web site.
Let the Webmaster know, please, if the PDF file was helpful to you.