Chapter 6 Using Decision Structures 169
- Click OK to close the message box.
- Experiment with other values for the SSN and PIN.
Test the program carefully to be sure that the welcome message is not displayed when
other PINs or SSNs are entered.
- Click the Close button on the form when you’re finished.
The program ends, and the development environment returns.
Tip You can further customize this program by using the PasswordChar property in
masked text box objects. The PasswordChar property can be used to display a placeholder
character, such as an asterisk (*), when the user types. (You specify the character by using
the Properties window .) Using a password character gives users additional secrecy as they
enter their protected password—a standard feature of such operations.
Short-Circuiting by Using AndAlso and OrElse
Visual Basic offers two logical operators that you can use in your conditional statements,
AndAlso and OrElse. These operators work the same as And and Or respectively, but
offer an important subtlety in the way they’re evaluated that is worth a few moments of
thoughtful consideration. However, they are also somewhat advanced, so if you would like
to skip this section (offered here for completeness sake) feel free to do so.
Consider an If statement that has two conditions that are connected by an AndAlso operator.
For the statements of the If structure to be executed, both conditions must evaluate to True.
If the first condition evaluates to False, Visual Basic skips to the next line or the Else statement
immediately, without testing the second condition. This partial, or short-circuiting, evaluation