Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Chapter 4 – Decisions 4.1 Relational and Logical Operators (see other set of slides) 4.2 If Blocks (see other set of slides) 4.3 Select Case Blocks (see.

Similar presentations


Presentation on theme: "1 Chapter 4 – Decisions 4.1 Relational and Logical Operators (see other set of slides) 4.2 If Blocks (see other set of slides) 4.3 Select Case Blocks (see."— Presentation transcript:

1 1 Chapter 4 – Decisions 4.1 Relational and Logical Operators (see other set of slides) 4.2 If Blocks (see other set of slides) 4.3 Select Case Blocks (see other set of slides) 4.4 Input via User Selection

2 Using a List Box for Input Using Radio Buttons for Input Using Check Boxes for Input Events Raised by Selections 2

3 The Three Types of Controls Used for Selection 3 list box radio buttons check boxes Which would you use for: Age? Ethnicity? Which would you use for: Age? Ethnicity?

4 Fill a List Box at Design Time via its String Collection Editor 4 Tasks button click here to invoke string collection editor

5 String Collection Editor 5 Fill by direct typing or by copying and pasting from a text editor or a spreadsheet.

6 List Box at Run Time 6 lstMonths selected item The value of lstMonths.Text is the string consisting of the selected item.

7 Example 4.4.1– Form Designer Items property Collections editor

8 Code 8 Selection by user

9 Output

10 10 The Group Box Control Group boxes are passive objects used to group other objects together. When you drag a group box, the attached controls follow as a unit. To attach controls to a group box, create the group box and then place the controls into the group box.

11 11 Group Box Example Three attached controls: Button1 Button2 Button3

12 12 Radio Button Properties To determine if the button is on or off radButton.Checked has value True if button is on. To turn a radio button on radButton.Checked = True Question: what is the data type of the RadioButton’s Checked property?

13 13 Example 3: Form radChild radAdult radSenior radMinor Radio buttons are intended for mutually exclusive choices. By placing them in a GroupBox control, you guarantee only one will be selected.

14 14 Example 4.4.3 If radChild.Checked Then txtFee.Text = FormatCurrency(0) ElseIf radMinor.Checked Then txtFee.Text = FormatCurrency(5) ElseIf radAdult.Checked Then txtFee.Text = FormatCurrency(10) ElseIf radSenior.Checked Then txtFee.Text = FormatCurrency(7.5) Else MessageBox.Show("Must make a selection.") End If

15 15 Example 4.4.3: Output

16 16 The Check Box Control Consists of a small square and a caption Presents the user with a Yes/No choice During run time, clicking on the check box toggles the appearance of a check mark. Checked property has value True when check box is checked and False when not CheckedChanged event is raised when the user clicks on the check box

17 17 Example 4.4.4: Form chkDrug chkDental chkVision chkMedical Check boxes are intended for allowing multiple selections. This happens regardless of whether or not they are placed in a GroupBox.

18 Example 4.4.4: Code for Button Dim sum As Double = 0 If chkDrugs.Checked Then sum += 39.15 End If If chkDental.Checked Then sum += 10.81 End If If chkVision.Checked Then sum += 2.25 End If If chkMedical.Checked Then sum += 55.52 End If txtTotal.Text = FormatCurrency(sum) 18

19 Example 4.4.4: Output 19

20 Events Raised by a Selection SelectedIndexChanged – raised when a new item of a list box is selected CheckedChanged - raised when the user clicks on an unchecked radio button or a check box; that is, when the value of the Checked property is changed. 20

21 21 Example 5: Code Here, a single event procedure is handling multiple events. In this case, whichever CheckBox’s Checked status gets changed will trigger the procedure to execute.

22 22 Example 5: Output


Download ppt "1 Chapter 4 – Decisions 4.1 Relational and Logical Operators (see other set of slides) 4.2 If Blocks (see other set of slides) 4.3 Select Case Blocks (see."

Similar presentations


Ads by Google