CByte Function
Collapse the table of content
Expand the table of content

CByte Function


Returns an expression that has been converted to a Variant of subtype Byte.


The expression argument is any valid expression.

Use the CByte function to provide conversions from any data type to a Byte subtype. For example, CByte forces byte arithmetic when currency, single-precision, double-precision, or integer arithmetic would normally occur.

The CByte function uses the locale setting of your system to determine how to perform conversions. Different decimal separators are properly recognized depending on the locale setting, as are different thousand separators.

If expression lies outside the acceptable range for the byte subtype, an error occurs.

The following 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.


Change History




September 2009

Modified remarks.

Customer feedback.

© 2015 Microsoft