If then assignments by sdfsb346f

VIEWS: 23 PAGES: 2

									If then assignments
If then….. a decision structure that executes code when a condition is true.
If guess = 10 then
        Msgbox “You guessed right”
End if
If the value of guess is not 10 then the assignment is not executed and the program flows
to the End if

IF condition THEN
       Statements
End if

Operator       Meaning
=              equal to
<              less than
<=             less than or equal to
>              greater than
>=             greater than or equal to
><             not equal

If then can include an Else clause
If condition then
Statements
Else
Statements
End if

If guess = 10 then
        Msgbox “You got it”
Else
        Msgbox “You are wrong”
End if

Mini assignment – create a program that ask the user for a number, it then tells them if
they are correct or incorrect


Nested If then Else
If guess = 10 then
        Msgbox “You got it”

Else
       Msgbox “You are wrong”
       If guess < 10 then
               Msgbox “Too low”
       Else
              Msgbox “Too high”

End if


What is the result of this program?
If intscore >=100 then
         Lblmessage.caption = “You won!”
Else
if intscore < 100 then
         Lblmesage.caption = “Good Try”
Else
If intscore < 50 then
         Lblmessage.caption = “Practice More”
Does the output reflect what was intended?

								
To top