CBool Function

Description

Converts an expression to a Boolean.

Syntax

CBool(expression)

The expression argument is any valid numeric or string expression.

Remarks

If expression is zero, False is returned; otherwise, True is returned. If expression can’t be interpreted as a numeric value, a run-time error occurs.

See Also

Data Type Summary.

Example

This example uses the CBool function to convert an expression to a Boolean. If the expression evaluates to a nonzero value, CBool returns True; otherwise, it returns False.


A = 5: B = 5                ' Initialize variables.= CBool(A = B)        ' Check contains True.= 0                    ' Define variable.= CBool(A)            ' Check contains False.