clearly visual basic: programming with visual basic 2008 chapter 14 do it, then ask permission

19
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 14 Do It, Then Ask Permission

Upload: franklin-day

Post on 18-Jan-2018

230 views

Category:

Documents


5 download

DESCRIPTION

Clearly Visual Basic: Programming with Visual Basic 2008 Testing after the Fact Instructions in a pretest loop –May never be processed Instructions in a posttest loop –Will be processed at least once Figure 14-1 –Shows the problem specification and algorithms 3

TRANSCRIPT

Page 1: Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 14 Do It, Then Ask Permission

Clearly Visual Basic: Programming with Visual Basic 2008

Chapter 14 Do It, Then Ask Permission

Page 2: Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 14 Do It, Then Ask Permission

Clearly Visual Basic: Programming with Visual Basic 2008

Objectives

• Write a posttest loop using the Do…Loop statement• Show a posttest loop in both pseudocode and a

flowchart• Concatenate strings

2

Page 3: Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 14 Do It, Then Ask Permission

Clearly Visual Basic: Programming with Visual Basic 2008

Testing after the Fact

• Instructions in a pretest loop – May never be processed

• Instructions in a posttest loop – Will be processed at least once

• Figure 14-1 – Shows the problem specification and algorithms

3

Page 4: Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 14 Do It, Then Ask Permission

Clearly Visual Basic: Programming with Visual Basic 2008 4

Page 5: Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 14 Do It, Then Ask Permission

Clearly Visual Basic: Programming with Visual Basic 2008 5

Page 6: Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 14 Do It, Then Ask Permission

Clearly Visual Basic: Programming with Visual Basic 2008 6

Page 7: Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 14 Do It, Then Ask Permission

Clearly Visual Basic: Programming with Visual Basic 2008 7

Page 8: Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 14 Do It, Then Ask Permission

Clearly Visual Basic: Programming with Visual Basic 2008 8

More on the Do … Loop Statement

• Pretest syntax– The {While | Until} condition section

• Part of the Do clause • Indicates that the condition is evaluated before the

loop instructions are processed

• Posttest syntax– The {While | Until} condition section

• Part of the Loop clause• Indicates that the condition is evaluated after the loop

instructions are processed

Page 9: Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 14 Do It, Then Ask Permission

Clearly Visual Basic: Programming with Visual Basic 2008 9

Page 10: Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 14 Do It, Then Ask Permission

Pseudocode and Flowchart for a Posttest Loop

• Figure 14-4 – Shows the pseudocode and flowchart for Example 2

in Figure 14-3• The repetition diamond

– Appears at the bottom of the loop in a posttest loop

Clearly Visual Basic: Programming with Visual Basic 2008 10

Page 11: Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 14 Do It, Then Ask Permission

Clearly Visual Basic: Programming with Visual Basic 2008

11

Page 12: Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 14 Do It, Then Ask Permission

The Good Morning Application

• Figure 14-5– Shows the interface for the Good Morning application

• Figure 14-6– Shows each message on a separate line in the

control• Figure 14-7

– Shows the pretest and posttest loops in the Good Morning application

– Describes the way the computer processes the code in each loop when the user enters the number 0

Clearly Visual Basic: Programming with Visual Basic 2008 12

Page 13: Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 14 Do It, Then Ask Permission

Clearly Visual Basic: Programming with Visual Basic 2008 13

Page 14: Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 14 Do It, Then Ask Permission

Clearly Visual Basic: Programming with Visual Basic 2008 14

Page 15: Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 14 Do It, Then Ask Permission

Clearly Visual Basic: Programming with Visual Basic 2008 15

Page 16: Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 14 Do It, Then Ask Permission

Clearly Visual Basic: Programming with Visual Basic 2008 16

Page 17: Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 14 Do It, Then Ask Permission

But They Said There Were No Strings Attached

• Concatenation operator– The ampersand (&)– Used to concatenate (connect or link) strings

together• ControlChars.NewLine constant

– Represents the Enter key on your keyboard – Used to create a new line

Clearly Visual Basic: Programming with Visual Basic 2008 17

Page 18: Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 14 Do It, Then Ask Permission

Clearly Visual Basic: Programming with Visual Basic 2008 18

Page 19: Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 14 Do It, Then Ask Permission

Summary

• Instructions in a posttest loop – Will be processed at least once

• Do…Loop statement – Used to code a posttest loop

• To concatenate strings – Use the concatenation operator: ampersand (&)

• Enter key – Represented by the ControlChars.NewLine

constant

Clearly Visual Basic: Programming with Visual Basic 2008 19