- 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
3.4 If/Then/Else Selection Structure
The If/Then selection structure performs an indicated action only when the condition evaluates to true; otherwise, the action is skipped. The If/ThenElse / selection structure allows the programmer to specify that a different action be performed when the condition is true than that performed when the condition is false. For example, the statement
If studentGrade >= 60 Then Console.WriteLine("Passed") Else Console.WriteLine("Failed") End If
prints "Passed" if the student's grade is greater than or equal to 60 and prints "Failed" if the student's grade is less than 60. In either case, after printing occurs, the next statement in sequence is "performed."