CBool Function

Converts a string comparison or numeric comparison to a Boolean expression, or converts a single numeric expression to a Boolean expression.

தொடரமைப்பு:


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

Return value:

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.

பிழையான குறியீடுகள்:

5 செல்லாத செயல்முறை அழைப்பு

எடுத்துக்காட்டு:


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
    ' If Instr(Input, "and")<>0 Then...
    ' 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

Please support us!