Control Structures in Visual Basic .NET
- Introduction
- 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
- Summary
Objectives
To use the If/Then and If/Then/Else selection structures to choose among alternative actions.
To use the While, DoWhile/Loop and Do Until/Loop repetition structures to execute statements in a program repeatedly.
To use the assignment operators.
To use the For/Next, Do/LoopWhile and Do/LoopUntil repetition structures to execute statements in a program repeatedly.
To understand multiple selection as implemented by the Select Case selection structure.
To use the ExitDo and ExitFor program control statements.
To use logical operators.
Who can control his fate?
William Shakespeare
Man is a tool-making animal.
Benjamin Franklin
Intelligence... is the faculty of making artificial objects, especially
tools to make tools.
Henri Bergson
Let's all move one place on.
Lewis Carroll
Outline
3.1 |
Introduction |
3.2 |
Control Structures |
3.3 |
If/Then Selection Structure |
3.4 |
If/Then/Else Selection Structure |
3.5 |
WhileRepetition Structure |
3.6 |
DoWhile/Loop Repetition Structure |
3.7 |
DoUntil/Loop Repetition Structure |
3.8 |
Do/LoopWhile Repetition Structure |
3.9 |
Do/LoopUntil Repetition Structure |
3.10 |
Assignment Operators |
3.11 |
For/Next Repetition Structure |
3.12 |
Example: Using the For/Next Structure to Compute Compound Interest |
3.13 |
SelectCase Multiple-Selection Structure |
3.14 |
Using the Exit Keyword in a Repetition Structure |
3.15 |
Logical Operators |
3.16 |
Introduction to Windows Application Programming |
3.17 |
Summary |
3.1 Introduction
In this chapter, we present control structures that enable programmers to control the order of events in their programs. Visual Basic's sequence, selection and repetition structures are used to select and repeat various statements and thereby execute complex algorithms. In the process, we introduce commonly used shorthand operators that allow the programmer quickly to calculate and assign new values to variables. When we study object-based programming in more depth in Chapter 5, we will see that control structures are helpful in building and manipulating objects.