30.07.2013 Views

Visual Basic.NET How to Program (PDF)

Visual Basic.NET How to Program (PDF)

Visual Basic.NET How to Program (PDF)

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

674 Strings, Characters and Regular Expressions Chapter 15<br />

Fig. 15.22 Validating user information using regular expressions (part 5 of 5).<br />

When a user clicks the OK but<strong>to</strong>n, the program checks <strong>to</strong> make sure that none of the<br />

fields are empty (lines 36–39). If one or more fields are empty, the program signals the user<br />

that all fields must be filled before the program can validate the input information (lines<br />

42–43). Line 46 calls instance method Focus of class TextBox. Method Focus places<br />

the cursor within the TextBox that made the call. The program then exits the event handler<br />

(line 48). If there are no empty fields, the user input is validated. The Last Name is<br />

validated first (lines 52–60). If it passes the test (i.e., if the Success property of the<br />

Match instance is True), control moves on <strong>to</strong> validate the First Name (lines 63–71).<br />

This process continues until all TextBoxes are validated, or until a test fails (Success<br />

is False) and the program sends an appropriate error message. If all fields contain valid<br />

information, success is signaled, and the program quits.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!