CByte Function Description
The VBA CByte function converts an expression (variable) to Byte data type.
Syntax
The syntax for the CByte function in VBA is:
CByte( expression )
Parameters
expression
An expression / variable that is to be converted to Byte data type.
Other Notes
The Byte data type restricts value from 0 to 255. Converted fractions will be rounded (banker’s rounding algorithm).
Number higher that 255 and lower than 0 will throw Overflow error.
Example usage
The CByte function can be used in VBA code. Let’s look at some VBA CByte function examples:
CByte 10 'Result: 10 CByte "20" 'Result: 20 CByte 20.2 'Result: 20 CByte 20.6 'Result: 21