Innhald
Innhaldsliste 🔎︎

# CBool-funksjonen

Konverterer eit uttrykk eller ein serie med uttrykk til ein boolsk verdi. Eit uttrykk er sett saman av strengar, tal og operatorar. Samanlikningar, logiske eller matematiske operatorar er tillatne i uttrykk.

### Syntaks:

      CBool (expression As Variant) As Boolean

expression can be a number or a set of combined expressions.

### Returverdi:

Boolean

### Parametrar:

expression: A logical expression, a mathematical formula, a numeric expression or a set of expressions combined with operators. During expression evaluation logical operators take preceedence over comparison operators, which in turn take preceedence over mathematical operators.

The expression can be a number or mathematical formula. When equals to 0, False is returned, otherwise True is returned.

Multiple expressions such as expr1 [[{operator] expr2]..] can be combined. expr1 and expr2 can be any string or numeric expressions that you want to evaluate. CBool combines the expressions and returns either True or False. operator can be a mathematical operator, logical operator or comparison operator.

### Feilkodar

5 Ugyldig prosedyreoppkall

### Eksempel:

In the following examples, the CBool function evaluates a logical expression, a mathematical formula and the value that is returned by the Instr function. The function checks if the character "a" is found in the sentence that was entered by the user.

    Sub ExampleCBool
        Print CBool( 1>2 Xor 44 ) ' computes to True
        Print CBool( expression := 15 /2 -7.5 ) ' displays False as expression equals 0
        txt = InputBox("Please enter a short sentence:")
        ' Proof if the character "a" appears in the sentence.
        ' I staden for kommandolinja
        ' If Instr(Input, "a")<>0 Then...
        ' vert CBool-funksjonen brukt slik:
        If CBool(Instr(txt, "a")) Then
            MsgBox "The character »a« appears in the sentence you entered!"
        EndIf
    End Sub

Liknande emne

CByte Function

CCur-funksjonen