CByte Function

 

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

Syntax

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

Change History

Date

History

Reason

September 2009

Modified remarks.

Customer feedback.

See Also

CBool Function
CCur Function
CDate Function
CDbl Function
CInt Function
CLng Function
CSng Function
CStr Function