Partager via


CByte Function

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

                      CByte(expression)

Remarks

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.

Requirements

Version 1

See Also

Reference

CBool Function

CCur Function

CDate Function

CDbl Function

CInt Function

CLng Function

CSng Function

CStr Function

Change History

Date

History

Reason

August 2009

Modified remarks.

Customer feedback.