CBOOL(expression)

Returns the expression converted to a boolean data type (Boolean).


expressionThe expression to evaluate and convert to a boolean.

REMARKS
* This function will convert any numerical value into a boolean value.
* The "expression" can be any valid string or numeric expression.
* If the expression passed to the function is outside the range of the data type being converted to, an error occurs.
* Numeric non-zero values are converted to True.
* The strings "True" and "False" are converted to True and False respectively.
* For a full list of conversion functions refer to the Explicit Conversion page.
* For the Microsoft documentation refer to docs.microsoft.com

Debug.Print CBool(1)           '= True  
Debug.Print CBool(0) '= False
Debug.Print CBool(-1) '= True
Debug.Print CBool("0") '= False
Debug.Print CBool("1") '= True
Debug.Print CBool("-1") '= True
Debug.Print CBool(100) '= True
Debug.Print CBool(-100) '= True
Debug.Print CBool("some text") '= Type mismatch

© 2021 Better Solutions Limited. All Rights Reserved. © 2021 Better Solutions Limited Top