Module-207
Module-207
(Flow of Control)
• Control structures specify the order in which tasks are execution .
• There three main control structures:
• Sequence
• Selection(Decision Structure)
• Iteration(Loop or Repetition)
• Sequence: statements are executed one after another – the default
• Selection: statement is executed base on condition
• Iteration: statements executed a number of time
Selection cont.
• Selection Statements is classify into two types
• Single selection(one-way)
• Dual selection(two-way)
• One-way selection statement:
• Evaluates logical expression
• Executes statements only if expression is true
• Two-way selection statement:
• Evaluates logical expression
• Executes statements if it is true
• Executes different statements if it is false
Selection cont.
• Single (One-way) Selection flowchart
Selection
• Make decisions in selection statement by writing logical expressions
• Logical expression evaluates to true or false
• Use to compare two values
• Relational operator
• Use to make comparison in logical expression
Selection cont.
• The selection statement use in VB.NET include:
• If Then statement
• If Then Else statement
• Select Case statement
Selection cont.
• Writing one-way Selection statements
• Single-line If syntax:
If (condition) Then statement
• Multi-line If syntax:
If ( condition) Then
statement
.
statement
End If
Selection cont.
• Multi-line if:
• Nested If
• If statement written inside another If statement
• Can replace compound expression with nested If
Selection cont.
• Dual(Two-way) selection statement flowchart
Selection cont.
• Writing dual(two-way) selection statements
• Syntax:
If (condition) Then
statement(s)
Else
statement(s)
End If
• ElseIf
• Combines Else and If
If/Then/Else Selection Structure