Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 106 Computing Fundamentals II Chapter 35 “Controls For Choices”

Similar presentations


Presentation on theme: "CS 106 Computing Fundamentals II Chapter 35 “Controls For Choices”"— Presentation transcript:

1 CS 106 Computing Fundamentals II Chapter 35 “Controls For Choices”
Herbert G. Mayer, PSU CS Status 7/17/2013 Initial content copied verbatim from CS 106 material developed by CS professors: Cynthia Brown & Robert Martin

2 Syllabus Controls For Choices Option Button Creating Option Buttons
About the Demo Events

3 Controls for Choices Let’s look at new controls: option buttons and check boxes These controls are designed to be used when you want the user of the program to have choices We’ll use conditionals to determine which values have been set and have the program act accordingly

4 Option Buttons Option buttons come in groups, but only one button in the group can be selected We use the prefix opt for this control. Let’s say there are three buttons in a group for choosing a size, Small, Medium, or Large We can name our buttons optSmall, optMedium, and optLarge

5 Creating Option Buttons
Generally start with a frame!! Then place Option Buttons into the frame; such as: Choose the Option Button tool in the Toolbox and create as many as you want in a group Name the buttons and change their text Notice that the buttons are round You are now ready to use them in a program

6 Check Boxes Check boxes are similar to option buttons but more than one in a group can be checked While option buttons make sense for choosing something like model or color, check boxes can be used for choosing something like features, where more than one can be chosen (AC, disk brakes, super sound package, leather seats, fancy wheels, etc.)

7 Creating Check Boxes It’s the same procedure as for option buttons, but the frame is optional Yet if you pick a frame, create it first The logic of the associated conditional will be different since more than one can be checked We’ll use the prefix chk for these named control

8 OptionDemo: If statements, check boxes, option buttons, demonstrated by showing HW3

9 About the Demo Check if an option -or check box- Value is True to see if it is selected: If chkTaller.Value Then btnPush.Height = btnPush.Height * 2 End If ‘ sometimes programmers code: If chkTaller.Value = True Then

10 Events Checking a box or selecting a button is an event. But if there is no code for an event, nothing happens There is no code for the event of selecting the red, blue, and green buttons. In HW3, their values are checked during the btnPush click event


Download ppt "CS 106 Computing Fundamentals II Chapter 35 “Controls For Choices”"

Similar presentations


Ads by Google