Lecture 10 - For and Do Loops

# Lecture 10 - For and Do Loops - TODAYS TOPICS Loops Engr...

This preview shows pages 1–4. Sign up to view the full content.

2/10/2010 1 TODAY’S TOPICS : : Loops Engr 160 Loops How will learning this help me? • Learning to use loops in your programs will save you the time of repeating the same calculations. • You can generate a lot of data quickly by using loops. Repeating a Calculation • How do you repeat a calculation? Engr 160

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

View Full Document
2/10/2010 2 Do Loops • The form is like this Do • Repetitive calculations or instructions • If (this conditions is true) Then Exit Do Loop Let’s trace a Do Loop Engr Engr Engr 160 160 160 Do Loop Trace This do loop will continue to ½ a number until it’s value is < 1.0 Number=InputBox(“enter a number between 100 and 200”) Do Number = number*.5 If(number < 1) Then Exit Do Loop Engr 160
2/10/2010 3 Sample Do Loop Engr 160 Sub looping_examples() ' ' looping_examples Macro ' ' Dim Number As Single Number = InputBox("Input a number between 100 and 200") Do Number = 0.5 * Number If (Number < 1) Then Exit Do

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 02/09/2012 for the course ENGR 160 taught by Professor Sengupta during the Spring '07 term at Iowa State.

### Page1 / 7

Lecture 10 - For and Do Loops - TODAYS TOPICS Loops Engr...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online