Sams Teach Yourself Visual Basic 6 in 24 Hours

Sams Teach Yourself Visual Basic 6 in 24 Hours

By Greg Perry

Q&A

  1. How can I guard against infinite loops?

    All loops continue as long as a condition is true or as long as a condition is false. Therefore, somewhere inside the loop's body your code must modify the condition used for the loop. The For loop's control variable must reach its ending value or something inside the Do loop's condition must change inside the loop's body. If the body of a loop doesn't change the controlling condition, the loop will execute forever.

  2. How do I terminate an infinite loop?

    As the lesson states, you must press Ctrl+Break to terminate an infinite loop. Until this lesson, you had not heard of Ctrl+Break, but the keystroke has been the program-stopping keystroke for many versions of the BASIC language through the years. In addition, you can click on VB's End toolbar button or select Run | End from the menu.

Share ThisShare This

Informit Network