# Keyword Reference

# If...ElseIf...Else...EndIf

Conditionally run statements.

If <expression> Then
statements
...
[ElseIf expression-n Then
[elseif statements ... ]]
...
[Else
[else statements]
...
EndIf

## Parameters

expression | If the expression is true, the first statement block is executed. If not, the first true ElseIf block is executed. Otherwise, the "Else" block is executed.

## Remarks

If statements may be nested.
The expression can contain the boolean operators of And, Or, and Not as well as the logical operators <, <=, >, >=, =, ==, and <> grouped with parentheses as needed.

## Related

If...Then, Select...Case...EndSelect, Switch...EndSwitch, Ternary

## Example

    #include <MsgBoxConstants.au3>

    Local $sString = ""
    If $sString > 0 Then
        MsgBox($MB_SYSTEMMODAL, "", "Value is positive.")
    ElseIf $sString < 0 Then
        MsgBox($MB_SYSTEMMODAL, "", "Value is negative.")
    Else
        If StringIsXDigit($sString) Then
            MsgBox($MB_SYSTEMMODAL, "", "Value might be hexadecimal!")
        Else
            MsgBox($MB_SYSTEMMODAL, "", "Value is a string.")
        EndIf
    EndIf