CByte Function

Updated: August 2009

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


                      CByte(expression)

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.

Date

History

Reason

August 2009

Modified remarks.

Customer feedback.

Community Additions

Show:
© 2014 Microsoft