IBM Lotus Symphony


If...Then...Else 语句 [运行时]

定义一个或多个仅当给定条件为 True 时才会执行的语句块。

语法:

If condition=true Then Statement block [ElseIf condition=true Then] Statement block [Else] Statement block EndIf Instead of Else If you can write ElseIf, instead of End If you can write EndIf.

参数:

If...Then 语句根据给定的条件来执行程序块。当 Lotus® Symphony™ Basic 遇到 If 语句时,会测试其条件。如果条件为 True,将执行所有后续语句直到遇到下一个 ElseElseIf 语句。如果条件为 False,并且后面有 ElseIf 语句,那么 Lotus Symphony Basic 测试下一个条件,如果该条件为 True,请执行后面的语句。如果仍为 False,程序将继续测试下一步 ElseIfElse 语句。仅当先前测试的条件都不为 True 时,才会执行 Else 后面的语句。对所有条件进行求值并执行相应语句后,程序将继续执行 EndIf 后面的语句。

If...Then 语句可以多层嵌套。

ElseelseIf 语句是可选语句。

警告图标 您可以使用 GoToGoSub 跳出 If...Then 块,但不能跳入 If...Then 结构。

以下示例可用于输入产品的截止日期并确定产品是否已超过截止日期。

示例:

Sub ExampleIfThenDate

Dim sDate as String

Dim sToday as String

sDate = InputBox("Enter the expiration date (MM.DD.YYYY) ")

sDate = Right$(sDate, 4) + Mid$(sDate, 4, 2) + Left$(sDate, 2)

sToday = Date$

sToday = Right$(sToday, 4) + Mid$(sToday, 4, 2) + Left$(sToday, 2)

If sDate < sToday Then

MsgBox "The expiration date has passed"

ElseIf sDate > sToday Then

MsgBox "The expiration date has not yet passed"

Else

MsgBox "The expiration date is today"

Loop Until sFile = ""

End Sub


产品反馈 | 其他文档 | 商标