CByte
Coerces an expression to a Byte.
Syntax: CByte( expression )
- expression
- required Any valid string or numeric expression in the range
0to255.
The return type is Byte. If expression is outside the range of a Byte, a run-time error occurs. Fractions are rounded — when the fractional part is exactly 0.5, CByte rounds to the nearest even number.
Example
This example uses the CByte function to convert an expression to a Byte.
Dim MyDouble, MyByte
MyDouble = 125.5678 ' MyDouble is a Double.
MyByte = CByte(MyDouble) ' MyByte contains 126.