- Control Structures
- If/Then Selection Structure
- If/Then/Else Selection Structure
- While Repetition Structure
- DoWhile/Loop Repetition Structure
- DoUntil/Loop Repetition Structure
- Do/LoopWhile Repetition Structure
- Do/LoopUntil Repetition Structure
- Assignment Operators
- For/Next Repetition Structure
- Example: Using the For/Next Structure to Compute Compound Interest
- SelectCase Multiple-Selection Structure
- Using the Exit Keyword in a Repetition Structure
- Logical Operators
- Introduction to Windows Application Programming
3.2 Control Structures
Normally, statements in a program are executed one after another in the order in which they are written. This process is called sequential execution. However, various Visual Basic statements enable the programmer to specify that the next statement to be executed might not be the next one in sequence. A transfer of control occurs when a statement other than the next one in the program executes.
Visual Basic provides seven types of repetition structures: While, DoWhile/Loop,
Do/LoopWhile, DoUntil/Loop, Do/LoopUntil, For/Next and ForEach/Next. (ForEach/Next is covered in Chapter 4, Procedures and Arrays.) The words If, Then, Else, End, Select, Case, While, Do, Until, Loop, For, Next and Each are all Visual Basic keywords. (See Fig. 3.1 for a list of all the Visual Basic keywords.) We discuss many of Visual Basic's keywords and their respective purposes throughout this book.
Fig. 3.1 Keywords in Visual Basic.