Visual Basic 2008 Programming: Business Applications with a Design Perspective
Chapter 1 Chapter 2 Chapter 3 Chapter 4 Chapter 5 Chapter 6 Chapter 7 Chapter 8 Chapter 9
Chapter 10 Chapter 11 Chapter 12 Chapter 13 Chapter 14 Appendix A Appendix B Appendix C Home
Loading
Last change: February 13 2016 18:48:19.

 Chapter in PDF

Table of Contents

Chapter 10: Special Topics in Data Entry
Last change: February 13 2016 18:47:25.
<<PreviousNext>>

10.4 Checking for Data-Entry Errors

From the user’s viewpoint, the user wants to be informed of an error at the point of its occurrence. This enables the user to make the correction immediately without having to look back for the source data, so the timing in checking for the error is exactly at the point of the error. An error can occur at one of the following three points:

This section considers checking for errors at each of these three points.

Tip
The concepts and techniques involved in this section can be fairly complicated. The most effective way to learn the materials is to work along as you read.
To illustrate how error checking can be implemented at each of the three levels, a simplified W-4 data-entry form will be used as an example. Its visual interface appears in Figure 10-2.

Figure 10-2
Simplified W-4 data-entry form

 

The following table gives the controls used for the data fields and the settings of certain selected properties.

Field Control Property Setting Remark
Employee Number Text box Name txtEmpNo 4 digits, numeric
Employee Name Text box Name txtEmpName Last, First Initial
Date of Employment Masked text box Name mskDateOfEmp To illustrate mask
checking
Mask ##-???-####
Zip Code Combo box Name cboZipCode User can select or enter a new Zip code
Number of Dependents Text box Name txtDependents three digits, numeric

The TabIndex properties of these controls are properly set by row and top-down; that is, the label with the text Employee Number has a TabIndex of zero; txtEmpNo, 1; and so forth.

Notice in particular that the masked text box mskDateOfEmp has a mask “##-???-####” that expects two digits for the day of the month, three characters for the month, and four digits for the year. Some programmers maintain that such a field design ensures no confusion between month and day; however, it can also cause inconvenience to the user. It requires the user’s familiarity. In addition, correcting an entry error can take additional effort. The design is used here simply for the purpose of illustrating how to handle a mask with mixed key types. Notice also that it is assumed when the program starts, the combo box cboZipcode will be populated with Zip codes stored in the employee database; however, the user can either select a Zip code from its list box, or enter one directly.

Last change: February 13 2016 18:47:24.
  1. Detecting Unsaved Data
  2. Handling Unsaved Data When Quitting
  • 10.4 Checking for Data-Entry Errors
    1. Checking a Pressed Key
    2. Checking Validity of Data Fields
    3. Form Level Validation
    4. <<PreviousNext>>