© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 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
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 2 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.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Test-Driving the Security Panel Application
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Test-Driving the Security Panel Application Load the Wage Calculator application –Debug > Start
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Test-Driving the Security Panel Application Figure 12.1 Security Panel application executing. TextBox Output ListBox Keypad
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Test-Driving the Security Panel Application Figure 12.2 Asterisks displayed in Security code: field. An asterisk is displayed for each numeric key pressed
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Test-Driving the Security Panel Application Entering invalid code – Enter 1212 – Click # Button
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Test-Driving the Security Panel Application Figure 12.3 Security Panel displaying Access Denied message. Message indicating that an invalid security code was entered
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Test-Driving the Security Panel Application Entering valid code –Enter 1006 –Click # Button
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved 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
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved 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
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Introducing the Select Case Multiple- Selection Statement Figure 12.5 Select Case multiple-selection statement UML activity diagram.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Constructing the Security Panel Application
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Constructing the Security Panel Application
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Constructing the Security Panel Application Figure 12.7 Variable declarations for btnEnter_Click. Declaring event handlers variables Declaring variables Clearing the TextBox
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Constructing the Security Panel Application Creating Case statement –Specify a range of values using: Keyword Is Comparison operator (in this case, < )
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Constructing the Security Panel Application Figure 12.8 Select Case statement. Creating a Select Case statement Create Select Case statement – Set controlling expression
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved 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
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved 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
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Constructing the Security Panel Application Figure 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
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Constructing the Security Panel Application Creating a Case Else statement –Use keywords Case Else –Must follow all other Case statements
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Constructing the Security Panel Application Figure Case Else of the Select Case statement. Case Else statement executes when no other Case matches
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Constructing the Security Panel Application Date structure –Stores and displays date and time information –Property Now returns: System time as a Date
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Constructing the Security Panel Application Figure Updating the Security Panel applications ListBox.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Constructing the Security Panel Application Figure Event handler btnZero_Click. Appending 0 to the end of a String
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Constructing the Security Panel Application Figure Event handlers btnOne_Click and btnTwo_Click. Appending 1 and 2 to the end of a String
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Constructing the Security Panel Application Figure Event handler btnClear_Click defined. Clearing the TextBox
Outline © Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 28 SecurityPanel.vb (1 of 5) Retrieving access code and clearing TextBox Declaring variables Using a Select Case statement to determine user access level
Outline © Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 29 SecurityPanel.vb (2 of 5) Appending the numeric Button value to the text stored in the TextBox
Outline © Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 30 SecurityPanel.vb (3 of 5)
Outline © Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 31 SecurityPanel.vb (4 of 5)
Outline © Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 32 SecurityPanel.vb (5 of 5) Clearing the TextBox