If - Then - Else
This is probably the most common instruction used in most programming languages and it allows you to include decision making into your program.
If a particular condition is true, then execute this statement(s) otherwise execute that statement(s).
The condition is always a boolean expression that evaluates to either True or False.
This can be used to execute one or more lines conditionally.
Optional Else Clause
The Else clause is optional but can be useful when you want to execute statements for both conditions.
If you type EndIf as one word it will be automatically split into 2 for you.
The Else clause is optional and can be excluded if you only want to execute one statement based on only one condition.
You can exclude the "= True" part as this is implicit but including it makes your code easier to understand.
One Line Versions
An alternative to the 'If-Then-Else-End If' and 'If-Then-End If' are the one line versions.
If you have one statement for when the condition is true, this can be condensed to one line.
If you are including a second statement for when the condition is NOT true, this can also be condensed to one line.
Condensing your code to one line makes it a lot harder to read and very hard to debug.
Exit If Statement
You can exit an If statement at any point using the Exit If statement.
Nested If
You can place an If statement inside another If statement to create nested If statements.
Nested If statements are hard to read and very hard to debug.
When you have a complex set of choices always use a Select-Case statement instead.
ElseIf Statement
Instead of nesting your If statements another alternative is to use the ElseIf statement.
If the first If evaluates to False, then evaluate the first ElseIf.
The first ElseIf condition that evaluates to True will have its statements executed.
If none of the ElseIf conditions evaluate to True then the final Else is executed.
Long sequences of ElseIf are hard to read and very hard to debug.
When you have a complex set of choices always use a Select-Case statement instead.
It is worth mentioning that you don't have to finish with an Else, you could finish with an ElseIf.
Choose
The CHOOSE function can return the value from a list of values based on an index number.
This provides an alternative to the If-Then-Else condition
© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext