1 / 21

Clearly Visual Basic: Programming with Visual Basic 2008

Clearly Visual Basic: Programming with Visual Basic 2008. Chapter 9 Decisions, Decisions, Decisions. 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

ismael
Télécharger la présentation

Clearly Visual Basic: Programming with Visual Basic 2008

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. 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 Clearly Visual Basic: Programming with Visual Basic 2008

  3. 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 Clearly Visual Basic: Programming with Visual Basic 2008

  4. Clearly Visual Basic: Programming with Visual Basic 2008

  5. Clearly Visual Basic: Programming with Visual Basic 2008

  6. Clearly Visual Basic: Programming with Visual Basic 2008

  7. Clearly Visual Basic: Programming with Visual Basic 2008

  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 Clearly Visual Basic: Programming with Visual Basic 2008

  9. Clearly 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 Clearly Visual Basic: Programming with Visual Basic 2008

  11. Clearly Visual Basic: Programming with Visual Basic 2008

  12. Clearly Visual Basic: Programming with Visual Basic 2008

  13. Clearly 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 Clearly Visual Basic: Programming with Visual Basic 2008

  15. Clearly Visual Basic: Programming with Visual Basic 2008

  16. Clearly 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 Clearly Visual Basic: Programming with Visual Basic 2008

  18. Clearly Visual Basic: Programming with Visual Basic 2008

  19. Clearly 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 Clearly 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 Clearly Visual Basic: Programming with Visual Basic 2008

More Related