This documentation is archived and is not being maintained.

Control Flow

Left unregulated, a program proceeds through its statements from beginning to end. Some very simple programs can be written with only this unidirectional flow. However, most of the power and utility of any programming language comes from the ability to change execution order with control statements and loops.

Control-flow statements allow you to regulate the flow of your program's execution. Using control statements, you can write Visual Basic code that makes decisions and repeats actions. Another useful statement, With...End With, lets you execute a series of statements without having to requalify an object.

In This Section

Decision Structures
Describes control-flow statements used for branching.
Loop Structures
Discusses control-flow statements used to repeat processes.
With...End With Statements
Explains how to execute several statements on the same object.
Nested Control Statements
Covers control-flow statements inside other control-flow statements.
Exit Statement
Summarizes how to transfer control directly out of a control-flow statement.

Related Sections

Control Statement Changes in Visual Basic
Lists changes to the behavior and syntax of control-flow statements from previous versions of Visual Basic.
Control Flow Summary
Provides links to language reference topics on this subject.