Tutorial 12 – Security Panel Application Introducing the Select Case Multiple-Selection Statement Outline 12.1 Test-Driving the Security Panel Application 12.2 Introducing the Select Case Multiple-Selection Statement 12.3 Constructing the Security Panel Application 12.4 Wrap-Up
In this tutorial, you will learn to: Objectives In this tutorial, you will learn to: Use the Select Case multiple-selection statement. Use Case statements. Use the Is keyword. Display a date and time. Use TextBox property PasswordChar.
12.1 Test-Driving the Security Panel Application
12.1 Test-Driving the Security Panel Application Load the Wage Calculator application Debug > Start
12.1 Test-Driving the Security Panel Application Figure 12.1 Security Panel application executing. TextBox Keypad Output ListBox
12.1 Test-Driving the Security Panel Application Figure 12.2 Asterisks displayed in Security code: field. An asterisk is displayed for each numeric key pressed
12.1 Test-Driving the Security Panel Application Entering invalid code Enter 1212 Click # Button
12.1 Test-Driving the Security Panel Application Figure 12.3 Security Panel displaying Access Denied message. Message indicating that an invalid security code was entered
12.1 Test-Driving the Security Panel Application Entering valid code Enter 1006 Click # Button
12.1 Test-Driving the Security Panel Application Figure 12.4 Security Panel application confirming a valid security-code entry. Message displayed when a valid security code is entered
12.2 Introducing the Select Case Multiple-Selection Statement Select Case statement Begins with keywords Select Case followed by test expression Can contain optional Case Else statement Terminates with keywords End Select
12.2 Introducing the Select Case Multiple-Selection Statement Figure 12.5 Select Case multiple-selection statement UML activity diagram.
12.3 Constructing the Security Panel Application
12.3 Constructing the Security Panel Application
12.3 Constructing the Security Panel Application Figure 12.7 Variable declarations for btnEnter_Click. Declaring event handler’s variables Declaring variables Clearing the TextBox
12.3 Constructing the Security Panel Application Creating Case statement Specify a range of values using: Keyword Is Comparison operator (in this case, <)
12.3 Constructing the Security Panel Application Figure 12.8 Select Case statement. Creating a Select Case statement Create Select Case statement Set controlling expression
12.3 Constructing the Security Panel Application Figure 12.9 First Case added to Select Case statement. Is keyword can be used for relational and equality comparisons
12.3 Constructing the Security Panel Application Creating a Case statement Specifying a range of values using: Keyword To Checking for a specific number Specifying multiple expressions Use a comma to separate expressions
12.3 Constructing the Security Panel Application Figure 12.10 Cases specified for remaining access codes. To keyword can be used to specify a range of values to test. Comma used to separate multiple expressions in a Case
12.3 Constructing the Security Panel Application Creating a Case Else statement Use keywords Case Else Must follow all other Case statements
12.3 Constructing the Security Panel Application Figure 12.11 Case Else of the Select Case statement. Case Else statement executes when no other case matches
12.3 Constructing the Security Panel Application Date structure Stores and displays date and time information Property Now returns: System time as a Date
12.3 Constructing the Security Panel Application Figure 12.12 Updating the Security Panel application’s ListBox.
12.3 Constructing the Security Panel Application Figure 12.13 Event handler btnZero_Click. Appending “0” to the end of a String
12.3 Constructing the Security Panel Application Figure 12.14 Event handlers btnOne_Click and btnTwo_Click. Appending “1” and “2” to the end of a String
12.3 Constructing the Security Panel Application Figure 12.15 Event handler btnClear_Click defined. Clearing the TextBox
Using a Select Case statement to determine user access level SecurityPanel.vb (1 of 5) Declaring variables Retrieving access code and clearing TextBox Using a Select Case statement to determine user access level
SecurityPanel.vb (2 of 5) Appending the numeric Button value to the text stored in the TextBox
SecurityPanel.vb (3 of 5)
SecurityPanel.vb (4 of 5)
SecurityPanel.vb (5 of 5) Clearing the TextBox