ch04 - Microsoft Visual Basic 2008 Reloaded Third Edition...

Info icon This preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon
Microsoft Visual Basic 2008: Reloaded Third Edition Chapter Four Making Decisions in a Program
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Microsoft Visual Basic 2008: Reloaded, Third Edition 2 Objectives After studying this chapter, you should be able to: Include the selection structure in pseudocode and in a flowchart Write an If…Then…Else statement Write code that uses comparison operators and logical operators Create a variable having block scope Concatenate strings
Image of page 2
Microsoft Visual Basic 2008: Reloaded, Third Edition 3 Objectives (continued) Use the ControlChars.NewLine constant Change the case of a string Generate random numbers
Image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Microsoft Visual Basic 2008: Reloaded, Third Edition 4 The Selection Structure Selection structure (or decision structure ): Used to select a path to take based on the outcome of a decision or comparison Condition : The decision to be made Results in a Boolean (True or False) answer Four forms of selection structure: If If/Else If/ElseIf/Else Case
Image of page 4
Microsoft Visual Basic 2008: Reloaded, Third Edition 5 The Selection Structure (continued) Figure 4-1: Selection structures you might use today
Image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Microsoft Visual Basic 2008: Reloaded, Third Edition 6 Writing Pseudocode for the If and If/Else Selection Structures If selection structure : contains one set of instructions to process when the condition is true If/Else selection structure : Contains two sets of instructions One set is processed when the condition is true The other set is processed when the condition is false True path : path to follow when condition is true False path : path to follow when condition is false
Image of page 6
Microsoft Visual Basic 2008: Reloaded, Third Edition 7 Figure 4-2: Examples of the If and If/Else selection structures written in pseudocode
Image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Microsoft Visual Basic 2008: Reloaded, Third Edition 8 Flowcharting the If and If/Else Selection Structures Flowchart uses standardized symbols to show the steps a computer must take Selection/repetition symbol : Diamond shape Represents both selection and repetition structures One flowline entering and two flowlines leaving
Image of page 8
Microsoft Visual Basic 2008: Reloaded, Third Edition 9 Figure 4-3: Examples of the If and If/Else selection structures in flowchart form
Image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Microsoft Visual Basic 2008: Reloaded, Third Edition 10 Coding the If and If/Else Selection Structures If…Then…Else statement : used to code the If and If/Else selection structures Else clause : an optional part of the If statement Condition must be a Boolean expression Must evaluate to either True or False Statement block : set of statements terminated by an Else or End If If…Then…Else statement can contain variables, literal constants, named constants, properties, methods, arithmetic operators, comparison operators, and logical operators
Image of page 10
Microsoft Visual Basic 2008: Reloaded, Third Edition 11 Coding the If and If/Else Selection Structures (continued) Figure 4-4: How to use the If/Then/Else statement to code the If/Then/Else selection structure
Image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern