Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
If statemet1
1. The Selection Structure
The if…then…Else and
Select Case Statement
Paramet Damchoo , lecturer
Business computer Department
Management science Faculty
Surattani ratjabhat University
2. The Selection Structure
You use the selection structure , also called
the decision structure, when you want a
program to make a decision or
comparison and then, based on the result
of that decision or comparison, to select
one of two paths. You will need to use
the selection structure to complete the
Math application.
3. Figure 1-1: Decisions you might need to make today
Example 1 Example 2
If it’s raining then If you have a test tomorrow then
wear a rain coat study tonight
bring an umbrella Otherwise
watch a movie
4. Coding the Selection Structure in
Visual Basic
• You use the if …then… Else
statement to code the selection
structure in Visual Basic. The syntax
of the If…Then…Else statement is
shown in figure 1-2
5. Figure 1-2: Syntax of If…Then…Else…Statement
If Condition Then
[instructions when the condition is true]
Else
[instructions when the condition is false]
End If
6. Figure1-3: lists the relational operators you can use
in the If…Then..Else statement ‘s condition
Relational Operator Meaning
= Equal to
> Greater than
>= Greater than or equal to
< Less than
<= Less than or equal to
<> Not equal to
7. Logical Operation
AND OR XOR
True True True Tru True True True Tru False
True Fals False e
Tru False True True e
Fal True
e e se
False True False Fals True True False Tru True
e e
False Fals False Fals False False False Fal False
e e se
Not
AND
True False
True False
OR
False
False
XOR
22. Syntax
• IF Condition-1 THEN
[instruction when condition is true]
ELSEIF Condition-2 THEN
[instruction when condition is true]
ELSE
[instruction when condition is false]
END IF
24. Condition
IF Class = 1 THEN
OUTPUT “Freshman “
ELSEIF Class = 2 THEN
OUTPUT “Sophomore”
ELSEIF Class = 3 THEN
OUTPUT “Junior”
ELSEIF Class = 4 THEN
OUTPUT “Senior”
ELSE
OUTPUT “Not is Student”
25. Problem Definition
• INPUT
– Class
Integer
• PROCESS
– condition
• OUTPUT
–
26.
27.
28.
29. Example-2
(Book Shop)
2
(News paper)
(Magazine)
5%
Not Sale
1
News paper 2