16
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 16 I’m on the Inside; You’re on the Outside

Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 16 I’m on the Inside; You’re on the Outside

Embed Size (px)

DESCRIPTION

Clearly Visual Basic: Programming with Visual Basic 2008 One Loop within Another Loop Repetition structures can be nested Programmer –Determines whether a problem’s solution requires a nested repetition structure Figure 16-1 –Shows problem specification and algorithm from Chapter 13 3

Citation preview

Page 1: Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 16 I’m on the Inside; You’re on the Outside

Clearly Visual Basic: Programming with Visual Basic 2008

Chapter 16 I’m on the Inside; You’re on the

Outside

Page 2: Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 16 I’m on the Inside; You’re on the Outside

Clearly Visual Basic: Programming with Visual Basic 2008

Objectives

• Nest repetition structures• Utilize a text box’s Multiline, ReadOnly, and

ScrollBars properties

2

Page 3: Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 16 I’m on the Inside; You’re on the Outside

Clearly Visual Basic: Programming with Visual Basic 2008

One Loop within Another Loop

• Repetition structures can be nested• Programmer

– Determines whether a problem’s solution requires a nested repetition structure

• Figure 16-1 – Shows problem specification and algorithm from

Chapter 13

3

Page 4: Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 16 I’m on the Inside; You’re on the Outside

Clearly Visual Basic: Programming with Visual Basic 2008

4

Page 5: Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 16 I’m on the Inside; You’re on the Outside

Clearly Visual Basic: Programming with Visual Basic 2008 5

Page 6: Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 16 I’m on the Inside; You’re on the Outside

Clearly Visual Basic: Programming with Visual Basic 2008

Clock Application

• Clock – Uses nested repetition structures to keep track of the

time– The minute hand

• Controlled by the inner (nested) loop• The hour hand is controlled by the outer loop

• Figure 16-3– Shows logic used by a clock’s hour and minute hands

• Figure 16-4 – Shows interface for the Clock application

6

Page 7: Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 16 I’m on the Inside; You’re on the Outside

Clearly Visual Basic: Programming with Visual Basic 2008

7

Page 8: Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 16 I’m on the Inside; You’re on the Outside

Clearly Visual Basic: Programming with Visual Basic 2008 8

Page 9: Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 16 I’m on the Inside; You’re on the Outside

Clearly Visual Basic: Programming with Visual Basic 2008

Revisiting the Monthly Payment Calculator Application

• Figure 16-6 – Shows the output, processing, input items, and

algorithm for the Monthly Payment Calculator application

– Application calculates and displays: • Monthly payments on a loan

– Payments are calculated using: • Principal and term entered by the user, along with a

loop that varies the annual interest rates from 4% through 7%

9

Page 10: Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 16 I’m on the Inside; You’re on the Outside

Clearly Visual Basic: Programming with Visual Basic 2008 10

Page 11: Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 16 I’m on the Inside; You’re on the Outside

Clearly Visual Basic: Programming with Visual Basic 2008 11

Page 12: Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 16 I’m on the Inside; You’re on the Outside

Clearly Visual Basic: Programming with Visual Basic 2008

Revisiting the Monthly Payment Calculator Application (continued)

• ScrollBars property – Indicates whether any scroll bars appear on the text

box• Multiline property

– Specifies whether the text can span more than one line in the control

• Setting the text box’s ReadOnly property to True– Prevents the user from editing the contents of a text

box

12

Page 13: Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 16 I’m on the Inside; You’re on the Outside

Clearly Visual Basic: Programming with Visual Basic 2008 13

Page 14: Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 16 I’m on the Inside; You’re on the Outside

Clearly Visual Basic: Programming with Visual Basic 2008

But I Want To Do It a Different Way

• Use two Do…Loop statements or one For…Next statement and one Do…Loop statement

14

Page 15: Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 16 I’m on the Inside; You’re on the Outside

Clearly Visual Basic: Programming with Visual Basic 2008

Summary

• Repetition structures can be nested• For a nested repetition structure to work correctly:

– It must be contained entirely within the outer repetition structure

• When a text box’s Multiline property is set to True:– It can accept multiple lines of text

15

Page 16: Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 16 I’m on the Inside; You’re on the Outside

Summary (continued)

• A text box’s ScrollBars property – Determines whether scroll bars appear on the

control• Setting the text box’s ReadOnly property to True

– Prevents the user from editing the contents of a text box

Clearly Visual Basic: Programming with Visual Basic 2008 16