0% found this document useful (0 votes)
7 views16 pages

Conditional Statements Lesson 4Q LMS

This document outlines the objectives and concepts of flow control structures in programming, specifically focusing on conditional statements in Visual Basic. It explains one-way, two-way, and ladder selection statements, detailing their syntax and how they function based on logical conditions. Additionally, it includes practical activities for implementing these concepts through programming exercises involving user input and grading systems.

Uploaded by

alysonbaetiong16
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views16 pages

Conditional Statements Lesson 4Q LMS

This document outlines the objectives and concepts of flow control structures in programming, specifically focusing on conditional statements in Visual Basic. It explains one-way, two-way, and ladder selection statements, detailing their syntax and how they function based on logical conditions. Additionally, it includes practical activities for implementing these concepts through programming exercises involving user input and grading systems.

Uploaded by

alysonbaetiong16
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Conditional Statements

Program Control Structures


Objectives
In this lesson you will:
• Learn about flow control structures
• Explore how to form conditional
statements
• Discover how to use the selection control
structures if then, if... then else,
if… then elseif ladder in a Visual
Basic program.
Flow Control Structures
• A computer can proceed:
− In sequence
− Selectively (branch) - making a choice
− Repetitively (iteratively) - looping
• Some statements are executed only if certain
conditions are met.
• A condition is represented by a logical
(Boolean) expression that can be true or false
• A condition is met if it evaluates to a true
value.
Flow Control Structures
• Unless specified otherwise, the order of
statement execution through a program is
linear: one statement after another in sequential
manner or called as sequential flow control.
• A conditional statement sometimes called as
selection statement is a programming language
statement that selects an execution path based
on a given condition and evaluates it to whether
true or false.
One-Way (if…then) Statement
• The syntax/structure of one-way selection is:

If (expression / condition) Then


statement
End If

• Statement is executed if the value of the


expression / condition is true. Statement is
bypassed (skipped) if the value is false;
program goes to the next statement(s) if there
are any.
Example (If… Then)
Two-Way (If…Then…Else) Statement
• Two-way selection takes the form:

If (expression / condition) Then


statement 1
Else
statement 2
End If

• If expression is true, statement1 is executed otherwise


statement2 will be executed. But both statements
cannot be executed altogether.
• Else will not contain any conditional expression thus
will not use the Then keyword.
Example (Two-Way If… Then… Else)
Ladder (If… Then… ElseIf) Statement
• Ladder selection takes the form:
If (expression / condition) Then
statement 1
ElseIf (expression / condition) Then
statement 2
ElseIf (expression / condition) Then
statement 3
Else
statement 4
End If
• If a problem will require you to have more than two (2) possible
outcomes or options then the if then else if statement should be
used.
• The If and Else should only be used once and the ElseIf
can be used multiple times in the program. conditions are evaluated
from the top downwards.
Example (Ladder If… Then… ElseIf)
Practical Activity
• Using the Ladder Statement with a logical operator,
create a program that will accept an input average
grade from the user and then display its’ equivalent
Letter Grade and Remarks based on the given table
below.
Average Grade Letter Grade Remarks
Less than 75 F Failed
75 to 79 E Fair
80 to 85 D Good
86 to 90 C Very Good
91 to 95 B Great
96 to 100 A Excellent
Practical (Challenge) Activity
• Use the example program design below.

*You will be needing five (5) labels one (1) textbox and
three (3) command buttons for this program.
Practical Activity
• You can change the design layout of your own program
if you wish to change it but make sure to have the same
target output for the program. DO NOT forget to apply
the proper naming convention first in your tools / objects
before coding…
*FILENAME : 4QPracAct1Name Ex. 4QPracAct1JoseRizal
Both for the Form and Project Files.

*** SAMPLE Fragment CODE (Display Button) for your Reference

You might also like