共用方式為


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.

In general, you can document your code using the subtype conversion functions to show that the result of some operation should be expressed as a particular data type rather than the default data type. For example, use CByte to force byte arithmetic in cases where currency, single-precision, double-precision, or integer arithmetic normally would occur.

Use the CByte function to provide internationally aware conversions from any other data type to a Byte subtype. For example, different decimal separators are properly recognized depending on the locale setting of your system, 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