Loop structures allow you to execute one or more lines of code repetitively. You can repeat the statements until a condition is true, until a condition is false, a specified number of times, or once for each object in a collection. The loop structures supported by Visual Basic include:
- While
- Do...Loop
- For...Next
- For Each...Next
In This Section
- While Statement
- Describes how to execute a block of statements while a condition is true.
- Do...Loop Statements
- Describes how to execute a block of statements until a condition is satisfied.
- For...Next Statements
- Describes how to execute a block of statements a specified number of times.
- For Each...Next Statements
- Describes how to execute a block of statements for each element in a collection.
- Faster For...Next Loops
- Explains how to optimize performance of loops.
Related Sections
- Decision Structures
- Explains control-flow statements used for branching.
- With...End With Statements
- Describes how to execute several statements on the same object.
- Nested Control Statements
- Explains control-flow statements inside other control-flow statements.
- Exit Statement
- Shows how to transfer control directly out of a control-flow statement.