Your SlideShare is downloading. ×
0
Microsoft Visual Basic 2005
BASICS
Lesson 9
Nested If Statements and
Radio Buttons
Microsoft Visual Basic 2005 BASICS 2
Objectives
 Use nested If statements.
 Use radio buttons.
 Use the Form Load event...
Microsoft Visual Basic 2005 BASICS 3
Using Nested If Statements
 Nested If statement
 An If statement placed inside anot...
Microsoft Visual Basic 2005 BASICS 4
Using Nested If Statements
(cont.)
Microsoft Visual Basic 2005 BASICS 5
Using Nested If Statements
(cont.)
Microsoft Visual Basic 2005 BASICS 6
Using Radio Buttons
 Radio buttons are similar to check boxes
with one important dif...
Microsoft Visual Basic 2005 BASICS 7
Using Radio Buttons (cont.)
 Using radio buttons
 Create a GroupBox to group the ra...
Microsoft Visual Basic 2005 BASICS 8
Using Radio Buttons (cont.)
Microsoft Visual Basic 2005 BASICS 9
Creating a GroupBox Control
 GroupBox control
 Container for other controls
 Contr...
Microsoft Visual Basic 2005 BASICS 10
Creating a GroupBox Control
(cont.)
Microsoft Visual Basic 2005 BASICS 11
Creating a GroupBox Control
(cont.)
Microsoft Visual Basic 2005 BASICS 12
Creating Radio Buttons in the
GroupBox
 Once the
GroupBox is
created
 Add radio
bu...
Microsoft Visual Basic 2005 BASICS 13
Setting Radio Button Name
and Text Properties
 Radio buttons need to be named
appro...
Microsoft Visual Basic 2005 BASICS 14
Setting Radio Button Name
and Text Properties (cont.)
Microsoft Visual Basic 2005 BASICS 15
Adding Code to the Radio
Buttons
 Coding radio buttons
 Requires that you think in...
Microsoft Visual Basic 2005 BASICS 16
Adding Code to the Radio
Buttons (cont.)
Microsoft Visual Basic 2005 BASICS 17
Processing the Data
 The final step
 Calculate the result and create the output.
Microsoft Visual Basic 2005 BASICS 18
Using a Form Load Event
Procedure
 Set the Checked property to True.
 The radio bu...
Microsoft Visual Basic 2005 BASICS 19
Using Select Case
 In a Select Case statement
 You specify a variable to test.
 Y...
Microsoft Visual Basic 2005 BASICS 20
Using Select Case (cont.)
 You can use conditional operators in a
Case statement.
Microsoft Visual Basic 2005 BASICS 21
Summary
 If statements can be nested to make
additional decisions within the code o...
Microsoft Visual Basic 2005 BASICS 22
Summary (cont.)
 Each If statement within a nested If
statement must end with the E...
Microsoft Visual Basic 2005 BASICS 23
Summary (cont.)
 The first step in creating a group of radio
buttons is to create a...
Microsoft Visual Basic 2005 BASICS 24
Summary (cont.)
 To associate a radio button with a
GroupBox, click the RadioButton...
Microsoft Visual Basic 2005 BASICS 25
Summary (cont.)
 Coding radio buttons involves using form-
level variables that car...
Microsoft Visual Basic 2005 BASICS 26
Summary (cont.)
 The Select Case statement allows you
to make multi-way selections....
Upcoming SlideShare
Loading in...5
×

Ppt lesson 09

1,039

Published on

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,039
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
26
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Ppt lesson 09"

  1. 1. Microsoft Visual Basic 2005 BASICS Lesson 9 Nested If Statements and Radio Buttons
  2. 2. Microsoft Visual Basic 2005 BASICS 2 Objectives  Use nested If statements.  Use radio buttons.  Use the Form Load event.  Use the Select Case statement.
  3. 3. Microsoft Visual Basic 2005 BASICS 3 Using Nested If Statements  Nested If statement  An If statement placed inside another If statement  When using nested If statements  It is important that you properly indent the code.
  4. 4. Microsoft Visual Basic 2005 BASICS 4 Using Nested If Statements (cont.)
  5. 5. Microsoft Visual Basic 2005 BASICS 5 Using Nested If Statements (cont.)
  6. 6. Microsoft Visual Basic 2005 BASICS 6 Using Radio Buttons  Radio buttons are similar to check boxes with one important difference.  Radio buttons appear in groups.  Only one button can be selected at a time.
  7. 7. Microsoft Visual Basic 2005 BASICS 7 Using Radio Buttons (cont.)  Using radio buttons  Create a GroupBox to group the radio buttons.  Create the radio buttons in the GroupBox.  Write code to use the radio buttons.
  8. 8. Microsoft Visual Basic 2005 BASICS 8 Using Radio Buttons (cont.)
  9. 9. Microsoft Visual Basic 2005 BASICS 9 Creating a GroupBox Control  GroupBox control  Container for other controls  Controls that you place inside a GroupBox are treated as one unit.  Option group  Radio buttons in a GroupBox  GroupBox most important properties  (Name) and Text
  10. 10. Microsoft Visual Basic 2005 BASICS 10 Creating a GroupBox Control (cont.)
  11. 11. Microsoft Visual Basic 2005 BASICS 11 Creating a GroupBox Control (cont.)
  12. 12. Microsoft Visual Basic 2005 BASICS 12 Creating Radio Buttons in the GroupBox  Once the GroupBox is created  Add radio buttons to the GroupBox.
  13. 13. Microsoft Visual Basic 2005 BASICS 13 Setting Radio Button Name and Text Properties  Radio buttons need to be named appropriately.  Use the Name property  The Text property  Specifies the message for the attached label
  14. 14. Microsoft Visual Basic 2005 BASICS 14 Setting Radio Button Name and Text Properties (cont.)
  15. 15. Microsoft Visual Basic 2005 BASICS 15 Adding Code to the Radio Buttons  Coding radio buttons  Requires that you think in an event-driven way  Use form-level variables as the scope.  To keep track of the option that has been selected
  16. 16. Microsoft Visual Basic 2005 BASICS 16 Adding Code to the Radio Buttons (cont.)
  17. 17. Microsoft Visual Basic 2005 BASICS 17 Processing the Data  The final step  Calculate the result and create the output.
  18. 18. Microsoft Visual Basic 2005 BASICS 18 Using a Form Load Event Procedure  Set the Checked property to True.  The radio button is selected.  When a form is loaded and opened  A special event called a Load event is triggered.  You can write an event procedure for the form’s Load event.
  19. 19. Microsoft Visual Basic 2005 BASICS 19 Using Select Case  In a Select Case statement  You specify a variable to test.  You then list a number of cases for which you want to test.  The first line in a Select Case statement  Specifies the data involved in the decision
  20. 20. Microsoft Visual Basic 2005 BASICS 20 Using Select Case (cont.)  You can use conditional operators in a Case statement.
  21. 21. Microsoft Visual Basic 2005 BASICS 21 Summary  If statements can be nested to make additional decisions within the code of the If statement.  It is important to indent the code in a nested If statement to make the code readable.
  22. 22. Microsoft Visual Basic 2005 BASICS 22 Summary (cont.)  Each If statement within a nested If statement must end with the End If statement.  Radio buttons appear in groups. Only one radio button in the group can be selected at a time.  Radio buttons are sometimes called option buttons.
  23. 23. Microsoft Visual Basic 2005 BASICS 23 Summary (cont.)  The first step in creating a group of radio buttons is to create a GroupBox control to contain the radio buttons. The controls within a GroupBox are treated as one unit.  The Text property of a GroupBox control specifies the text that appears at the top of the GroupBox.
  24. 24. Microsoft Visual Basic 2005 BASICS 24 Summary (cont.)  To associate a radio button with a GroupBox, click the RadioButton tool only once and draw the radio button in the GroupBox. If you double-click to create a radio button, it will not associate itself with the GroupBox.  The Text property of a GroupBox control specifies the text that appears on the label attached to the radio button.
  25. 25. Microsoft Visual Basic 2005 BASICS 25 Summary (cont.)  Coding radio buttons involves using form- level variables that carry values that reflect the selected radio button.  A form’s Load event procedure is executed each time a form is loaded and opened by the program.
  26. 26. Microsoft Visual Basic 2005 BASICS 26 Summary (cont.)  The Select Case statement allows you to make multi-way selections. The Case statements in a Select Case can test a range or use conditional operators.  Conditional operators in a Case statement must include the Is keyword.  As a default, the Case Else statement is applied if no other Case is true.
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×