IF condition THEN
Statements group 1
END IF
or
IF condition THEN
Statements group 1
ELSE
Statements group 2
END IF
or
IF condition THEN statement1
or
IF condition THEN statement1 ELSE Statement2
or
IF condition1 THEN
Statement Group 1
ELSEIF condition2 THEN
Statement Group 2
END IF
Description
To test a condition and then based on whether the condition is true of false, to conditionally execute other statements. If condition is true then the statements in Statement Group 1 are executed, otherwise the statements in Statement Group 2 are executed.
Condition may be a complex logical condition including the following elements:
AND operator
OR operator
NOT operator
Parentheses
>(Greater than sign)
<(Less than sign)
=(Equal sign)
<=(Less than or equal sign)
>=(Greater than or equal sign
<>(not equal sign)
Example
If amt=1000 then
Goto allDone
End if
If state="IL" then
Gosub IllinoisCalcs
Else
Gosub OtherSatesCalcs
End if
If state="IL" Or state="CA" then
Goto noTaxes
End if
If not salary <=2000 then 'This demonstrates the NOT operator
Taxes=salary * .32
End if
If CountyCode=20 then 'this demonstrates nesting of IF statements
TaxRate=.043
Else
If CountyCode=21 then
TaxRate=.041
Else
TaxRate=.039
End if
End if
If(Sex="Male" and Weight > 200) or (Sex="Female" and weight > 180) then
Msgbox "Lose Weight!"
End if
If Amount >10000 Then
LoanProcess1
Elseif Amount > 5000 Then
LoanProcess2
Elseif Amount > 1000 Then
LoanProcess3
End if
If Sex="Male" Then AgeLimit=65 else AgeLimit=50