CBool - VBScript
Overview
The CBool function converts a numeric or string expression to a Boolean.
Syntax
CBool(expression)
Where:
expressionis a numeric or string expression.
Options/Flags
None
Examples
Convert a numeric expression to a Boolean:
Dim a = 1
MsgBox CBool(a) ' Output: True
Convert a string expression to a Boolean:
Dim b = "true"
MsgBox CBool(b) ' Output: True
Common Issues
CBool may return False for non-numeric strings or empty strings.
Integration
CBool can be used with If statements to check conditions, or with other functions to perform conditional operations.
Related Commands
IsNumericIsDate