9.0

179
the following statements to be executed. If all are False then the Else's statements are executed. The ElseIf and
Else portions are optional.
Form 3: If objexpr
's type is the same type or a type descended from objtype the Then portion is executed.
See Also: Select Case
, Choose( ), IIf( ).
Example
Sub Main
S = InputBox
("Enter hello, goodbye, dinner or sleep:")
S = UCase
(S)
If S = "HELLO" Then Debug
.Print "come in"
If S = "GOODBYE" Then Debug
.Print "see you later"
If S = "DINNER" Then
Debug
.Print "Please come in."
Debug
.Print "Dinner will be ready soon."
ElseIf S = "SLEEP" Then
Debug
.Print "Sorry."
Debug
.Print "We are full for the night"
End
If
End
Sub
IIf Function
Syntax
IIf(condexpr, TruePart, FalsePart)
Group
Miscellaneous
Description
Return the value of the parameter indicated by condexpr. Both TruePart and FalsePart are evaluated.
Parameter Description
condexpr If this value is True then return TruePart. Otherwise, return FalsePart.
TruePart Return this value if condexpr is True.
FalsePart Return this value if condexpr is False.
See Also: If, Select Case, Choose( ).
Example
Sub Main
Debug
.Print IIf(1 > 0,"True","False") '"True"
End
Sub