Zebra0.com

visual-basic loopsVisual Basic: Windows Programming

Visual Basic: Windows Programming

Learn Visual Basic in FREE step-by-step lessons.

Loops in Visual Basic

A loop is a block of statements that is repeated. Visual Basic has three types of loops: while, for and do.

A loop has a Boolean expression to test. If the expression is true the statements in the block are executed and then the test is performed again. When the condition is false, the next statement after the loop is executed. A while loop and a for loop test a Boolean expression at the beginning, a do loop tests the Boolean expression at the end. While and for loops are executed zero or more times. Do loops are always executed at least once.

The Boolean expression is a check point: The decision is made to execute the entire loop or not. If the value of the Boolean expression changes during execution of the loop, the loop continues until the test is made again. The loop does not end in the middle if the variable changes.

Each pass through the loop is called an iteration.

Please study the material at each of the links below.

  1. A Demo loop program

  2. For Loops

  3. Step: change the increment

  4. While Loops

  5. While, cont.

  6. Endless loops

  7. Do Loops

  8. Nested Loops

  9. For Each Loops

  10. Graphics with Loops

GlossaryGlossary for loops lesson
Full Glossary