Contents
Index 🔎︎
\<bookmark_value\>CBool function\</bookmark_value\>

# CBool Function

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

## Syntax:

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

## Return value:

Bool

## Parameters:

\<emph\>Expression1, Expression2:\</emph\> Any string or numeric expressions that you want to compare. If the expressions match, the \<emph\>CBool\</emph\> function returns \<emph\>True\</emph\>, otherwise \<emph\>False\</emph\> is returned.

\<emph\>Number:\</emph\> Any numeric expression that you want to convert. If the expression equals 0, \<emph\>False\</emph\> is returned, otherwise \<emph\>True\</emph\> is returned.

The following example uses the \<emph\>CBool\</emph\> function to evaluate the value that is returned by the \<emph\>Instr\</emph\> function. The function checks if the word "and" is found in the sentence that was entered by the user.

### Error codes:

5 Invalid procedure call

## Example:

    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