Chapter 18. Program Control Statements
Program control statements tell an application which other statements to execute under a particular set of circumstances. They control the path that execution takes through the code. They include commands that tell the program to execute some statements but not others and to execute certain statements repeatedly.
The two main categories of control statements are decision (or conditional) statements and looping statements. The following sections describe in detail the decision and looping statements provided by Visual Basic .NET.
A decision or conditional statement represents a branch in the program. It marks a place where the program can execute one set of statements or another, or possibly no statements at all, depending on some condition. These include
Select Case statements.
Single Line If Then
If Then statement has two basic forms. The first allows the program to execute a single statement if some condition is true. The syntax is as follows:
If condition Then statement
If the condition is true, the program executes the statement. In the most common form of single-line
If Then statement, the statement is a single simple command (such as assigning a value to a variable or calling a subroutine).
The following example checks the
IsManager property. If
True, the statement sets the
Salary property to 90,000.
If emp.IsManager Then emp.Salary = 90000
The second form ...