IBM Lotus Symphony


CBool 函数 [运行时]

将字符串比较或数字比较的结果转换为布尔表达式,或者将单个数字表达式转换为布尔表达式。

语法:

CBool (Expression1 {= | <> | < | > | <= | >=} Expression2) 或 CBool (Number)

返回值:

布尔值

参数:

Expression1 和 Expression2:任何您想要比较的字符串或数字表达式。如果表达式匹配,CBool 函数将返回 True,否则返回 False

Number:任何您希望转换的数字表达式。如果表达式等于 0,将返回 False,否则返回 True

下面的示例使用 cBool 函数对 Instr 函数的返回值进行求值。此函数将检查用户输入的句子中是否含有单词“and”。

错误代码

5 无效的过程调用

示例:

Sub ExampleCBool

Dim sText As String

sText = InputBox("Please enter a short sentence:")

REM Proof if the word »and« appears in the sentence.

REM Instead of the command line

REM If Instr(Input, "and") <>0 Then...

REM the CBool function is applied as follows:

If CBool(Instr(sText, "and") ) Then

MsgBox "The word »and« appears in the sentence you entered!"

EndIf

End Sub


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