If...End If
Previous  Next

Description: Executes statements based on the set conditions

     Syntax:
     
' Multiple-line syntax:
If <condition> Then
        [<statements>]
[ElseIf <elseifCondition> Then]
        [<elseifStatements>]
[Else]
        [<elseStatements>]
End If

' Single-line syntax:
If <condition> Then [<statements>] [Else] [<statements>]

Part
Description
<condition>
Required. Expression. Must return true or false.
<statements>
Optional. One or more statements to execute if the condition returns true.
Then
Required.
<elseifCondition>
Required if ElseIf is used.
<elseifStatements>
Optional. One or more statements to execute if the ElseIf condition returns true.
<elseStatements>
Optional. One or more statements to execute if the previous conditionals return false.
End If
Required. Ends the If block.

Example:

        a = 1
        b = 2
        If a = b Then
                Print "A and B are the same"
        ElseIf a > b Then
                Print "A is greater than B"
        Else
                Print "B is greater than A"
        End If