Presentation is loading. Please wait.

Presentation is loading. Please wait.

Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 9 Decisions, Decisions, Decisions.

Similar presentations


Presentation on theme: "Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 9 Decisions, Decisions, Decisions."— Presentation transcript:

1 Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 9 Decisions, Decisions, Decisions

2 Clearly Visual Basic: Programming with Visual Basic 2008 Objectives Show the selection structure in both pseudocode and a flowchart Write If…Then…Else statements Include comparison operators in a selection structure’s condition Add a check box to an interface 2

3 Clearly Visual Basic: Programming with Visual Basic 2008 Someone Might Need to Make a Decision All computer programs are written using one or more of three control structures –Sequence, selection, or repetition Selection structure –Makes a decision and then takes appropriate action based on that decision Studying problem specification –Determines whether problem’s solution requires a selection structure 3

4 4Clearly Visual Basic: Programming with Visual Basic 2008

5 5

6 6

7 7

8 8 Going Beyond Rob’s Problems Figure 9-5 shows: –Problem specification that does not involve Rob, the mechanical man –Correct algorithm for the problem

9 9Clearly Visual Basic: Programming with Visual Basic 2008

10 The If … Then … Else Statement Comparison operators –Used to compare values Statement block –Set of statements contained in the true path and the false path All expressions containing a comparison operator –Will result in an answer of either True or False only 10Clearly Visual Basic: Programming with Visual Basic 2008

11 11

12 12Clearly Visual Basic: Programming with Visual Basic 2008

13 13Clearly Visual Basic: Programming with Visual Basic 2008

14 Examining Another Problem Specification Oval in a flowchart –Is the start/stop symbol Rectangle in a flowchart –Is the process symbol Parallelogram in a flowchart –Is the input/output symbol Diamond in a flowchart –Is called the selection/repetition symbol 14Clearly Visual Basic: Programming with Visual Basic 2008

15 15Clearly Visual Basic: Programming with Visual Basic 2008

16 16Clearly Visual Basic: Programming with Visual Basic 2008

17 Hey, That’s Not the Way I Would Have Done It Variable that has procedure scope –Can be used anywhere within the procedure Variable that has block scope –Can be used only within the statement block in which it is declared Block variable –Variable declared within a statement block 17Clearly Visual Basic: Programming with Visual Basic 2008

18 18Clearly Visual Basic: Programming with Visual Basic 2008

19 19Clearly Visual Basic: Programming with Visual Basic 2008

20 Summary Selection structure –One of the three control structures Indent instructions in a selection structure’s true path and its false path In Visual Basic –You can use the If…Then…Else statement to code the selection structure An expression containing a comparison operator –Will always evaluate to either True or False 20Clearly Visual Basic: Programming with Visual Basic 2008

21 Summary (continued) In a flowchart –The selection structure’s condition is represented by a diamond chk –The three-character ID used when naming check boxes Block variable –Has block scope 21Clearly Visual Basic: Programming with Visual Basic 2008


Download ppt "Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 9 Decisions, Decisions, Decisions."

Similar presentations


Ads by Google