Specifications

App - 7
If...Then...Else statement
Functions
The flow control statement which performs the execution with condition based on the
value of an expression
Format
If condition Then statements[Else elsestatements]
Or, the following syntax in block form can be used.
If condition Then
[statements]
[ElseIf condition-n Then
[elseifstatements]]...
[Else
[elsestatements]]
End If
The following shows the designated items of the If...Then...Else statement.
Designated items Description
condition Designates either of the following two expressions.
A mathematical expression or string expression evaluating True
or False
If the value of an argument condition is Null, the argument
condition is considered as False.
Expression in the TypeOf objectname Is objecttype format
The argument objectname is a reference of any object, and the
argument objecttype is any valid object type.
This expression returns True if the argument objectname is the
objecttype designated by the argument objecttype. In othe
r
cases, it returns False.
statements Executed when the argument condition is True.
Designates a series of statements divided with colon (:).
condition-n Same as argument condition
elseifstatements Designates a series of statement to be executed when the
argument condition-n is True.
elsestatements Designates a series of statements to be executed when any o
f
conditions (argument condition and condition-n) defined before
Else is not True.
Explanation
The single-line If...Then...Else statement (first syntax) is used in making a brief and
simple conditional judgment.
The If…Then...Else statement (second syntax) in block form can make a more structured
and flexible description compared to the single-line syntax.
In addition, the code readability and maintainability are improved, and debugging can be
easily performed.