CBool

Coerces an expression to a Boolean.

Syntax: CBool( expression )

expression
required Any valid string or numeric expression.

The return type is Boolean. If expression evaluates to a nonzero value, CBool returns True; otherwise, it returns False.

The data-type conversion functions document code by showing that the result of some operation should be expressed as a particular data type rather than the default data type.

Common Errors

Error When
6 (&H6), Overflow expression is a string that holds a number outside the range of a Double
13 (&HD), Type mismatch expression is a string that is not a number, True or False (a zero-length string included)
94 (&H5E), Invalid use of Null expression is Null

Example

This example uses the CBool function to convert an expression to a Boolean.

Dim A, B, Check
A = 5: B = 5             ' Initialize variables.
Check = CBool(A = B)     ' Check contains True.

A = 0                    ' Define variable.
Check = CBool(A)         ' Check contains False.

See Also