Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 15 I’m on the Inside; You’re on the Outside (Nested Loops) Clearly Visual Basic: Programming with Visual Basic 2010 2 nd Edition.

Similar presentations


Presentation on theme: "Chapter 15 I’m on the Inside; You’re on the Outside (Nested Loops) Clearly Visual Basic: Programming with Visual Basic 2010 2 nd Edition."— Presentation transcript:

1 Chapter 15 I’m on the Inside; You’re on the Outside (Nested Loops) Clearly Visual Basic: Programming with Visual Basic 2010 2 nd Edition

2 Objectives Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition 2 After studying Chapter 15, you should be able to: Nest repetition structures Utilize a text box’s Multiline, ReadOnly, and ScrollBars properties

3 One Loop within Another Loop Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition 3 Repetition structures can be nested Programmer Determines whether a problem’s solution requires a nested repetition structure Figure 15-1 Shows problem specification and algorithm from Chapter 12

4 Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition 4 Figure 15-1 Problem specification and algorithm for signing one book for each customer

5 Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition 5 Figure 15-2 Problem specification and algorithm for signing zero or more books for each customer

6 Clock Application Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition 6 Clock Uses nested repetition structures to keep track of time The second hand is controlled by the inner (nested) loop The minute hand is controlled by the outer loop Figure 15-3 shows logic used by clock’s minute and second hands Figure 15-4 shows interface for the Clock application

7 Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition 7 Figure 15-3 Logic used by a clock’s minute and second hands

8 Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition 8 Figure 15-4 Clock application’s user interface

9 Revisiting the Monthly Payment Calculator Application Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition 9 Figure 15-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 A loop that varies the annual interest rates from 4% through 7%

10 Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition 10 Figure 15-6 Planning information for the Monthly Payment Calculator application from Chapter 14

11 Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition 11 Figure 15-7 Planning information for the modified Monthly Payment Calculator application

12 Revisiting the Monthly Payment Calculator Application (cont’d.) Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition 12 ScrollBars property Indicates whether any scroll bars appear on the text box Multiline property Specifies whether the text box can accept and display multiple lines of text Setting the text box’s ReadOnly property to True Prevents user from editing contents of a text box

13 Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition 13 Figure 15-11 Click event procedure for the btnCalc control

14 But I Want To Do It a Different Way Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition 14 Use two Do…Loop statements or one For…Next statement and one Do…Loop statement

15 Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition 15 Figure 15-12 Modified Click event procedure for the btnCalc control

16 Summary Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition 16 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 and display multiple lines of text

17 Summary (cont’d.) Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition 17 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 contents of a text box


Download ppt "Chapter 15 I’m on the Inside; You’re on the Outside (Nested Loops) Clearly Visual Basic: Programming with Visual Basic 2010 2 nd Edition."

Similar presentations


Ads by Google