Lecture 10 - For and Do Loops

Lecture 10 - For and Do Loops - 2/10/2010 TODAYS TOPICS:...

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

View Full Document Right Arrow Icon
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
Background image of page 1

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

View Full DocumentRight Arrow Icon
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
Background image of page 2
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
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 7

Lecture 10 - For and Do Loops - 2/10/2010 TODAYS TOPICS:...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online