IBM Lotus Symphony
|
将字符串比较或数字比较的结果转换为布尔表达式,或者将单个数字表达式转换为布尔表达式。
CBool (Expression1 {= | <> | < | > | <= | >=} Expression2) 或 CBool (Number)
布尔值
Expression1 和 Expression2:任何您想要比较的字符串或数字表达式。如果表达式匹配,CBool 函数将返回 True,否则返回 False。
Number:任何您希望转换的数字表达式。如果表达式等于 0,将返回 False,否则返回 True。
下面的示例使用 cBool 函数对 Instr 函数的返回值进行求值。此函数将检查用户输入的句子中是否含有单词“and”。
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