Executable Statements
An executable statement performs an action. It can call a procedure, branch to another place in the code, loop through several statements, or evaluate an expression. An assignment statement is a special case of an executable statement.
The following example uses an If...Then...Else control structure to run different blocks of code based on the value of a variable. Within each block of code, a For...Next loop runs a specified number of times.
Public Sub startWidget(ByVal aWidget As widget, _
ByVal clockwise As Boolean, ByVal revolutions As Integer)
Dim counter As Integer
If clockwise = True Then
For counter = 1 To revolutions
aWidget.spinClockwise()
Next counter
Else
For counter = 1 To revolutions
aWidget.spinCounterClockwise()
Next counter
End If
End Sub
The If statement in the preceding example checks the value of the parameter clockwise. If the value is True, it calls the spinClockwise method of aWidget. If the value is False, it calls the spinCounterClockwise method of aWidget. The If...Then...Else control structure ends with End If.
The For...Next loop within each block calls the appropriate method a number of times equal to the value of the revolutions parameter.