CBool Function
рдХрд┐рд╕реА рднреА рд╕реНрдЯреНрд░рд┐рдВрдЧ рдпрд╛ рдиреНрдпреВрдореЗрд░рд┐рдХ рдХрдореНрдкреЗрд░рд┐рдЬрд╝рди рдХреЛ рдмреВрд▓рд┐рдП рдПрдХреНрд╕рдкреНрд░реЗрд╢рди рдореЗрдВ рдмрджрд▓рддрд╛ рд╣реИ, рдпрд╛ рдПрдХрд▓ рдиреНрдпреВрдореЗрд░рд┐рдХ рдПрдХреНрд╕рдкреНрд░реЗрд╢рди рдХреЛ рдмреВрд▓рд┐рдП рдПрдХреНрд╕рдкреНрд░реЗрд╢рди рдореЗрдВ рдмрджрд▓рддрд╛ рд╣реИ.
Syntax:
CBool (Expression1 {= | <> | < | > | <= | >=} Expression2) or CBool (Number)
рд╡рд╛рдкрд╕реА рдореВрд▓реНрдп:
Bool
рдкреИрд░рд╛рдореАрдЯрд░
Expression1, Expression2: Any string or numeric expressions that you want to compare. If the expressions match, the CBool function returns True, otherwise False is returned.
Number: Any numeric expression that you want to convert. If the expression equals 0, False is returned, otherwise True is returned.
The following example uses the CBool function to evaluate the value that is returned by the Instr function. The function checks if the word "and" is found in the sentence that was entered by the user.
рдЙрджрд╛рд╣рд░рдг:
Sub ExampleCBool
Dim sText As String
sText = InputBox("Please enter a short sentence:")
' Proof if the word ┬╗and┬л appears in the sentence.
' Instead of the command line
REM If Instr(Input, "and")<>0 Then...
REM CBool рдлрд╝рдВрдХреНрд╢рди рдирд┐рдореНрдирд╛рдиреБрд╕рд╛рд░ рд▓рд╛рдЧреВ рдХрд┐рдпрд╛ рдЬрд╛рддрд╛ рд╣реИ:
If CBool(Instr(sText, "and")) Then
MsgBox "The word ┬╗and┬л appears in the sentence you entered!"
EndIf
End Sub