Clearly Visual Basic Programming with Visual Basic 2008
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 16 I’m on the Inside; You’re on the Outside
Objectives • Nest repetition structures • Utilize a text box’s Multiline, Read. Only, and Scroll. Bars properties Clearly Visual Basic: Programming with Visual Basic 2008 2
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 Clearly Visual Basic: Programming with Visual Basic 2008 3
Clearly Visual Basic: Programming with Visual Basic 2008 4
Clearly Visual Basic: Programming with Visual Basic 2008 5
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 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
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% Clearly Visual Basic: Programming with Visual Basic 2008 9
Clearly Visual Basic: Programming with Visual Basic 2008 10
Clearly Visual Basic: Programming with Visual Basic 2008 11
Revisiting the Monthly Payment Calculator Application (continued) • Scroll. Bars 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 Read. Only property to True – Prevents the user from editing the contents of a text box Clearly Visual Basic: Programming with Visual Basic 2008 12
Clearly Visual Basic: Programming with Visual Basic 2008 13
But I Want To Do It a Different Way • Use two Do…Loop statements or one For…Next statement and one Do…Loop statement Clearly Visual Basic: Programming with Visual Basic 2008 14
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 Clearly Visual Basic: Programming with Visual Basic 2008 15
Summary (continued) • A text box’s Scroll. Bars property – Determines whether scroll bars appear on the control • Setting the text box’s Read. Only property to True – Prevents the user from editing the contents of a text box Clearly Visual Basic: Programming with Visual Basic 2008 16
- Slides: 16