Skip to content

CByte - Built-in Conversion Function

See Also

Conversion functions

Purpose

CByte returns an expression converted to a byte.

Syntax

CByte(exp)

Arguments

Argument Required Description
exp Yes Any valid expression

Returns

Byte

Example

Let nTest = 125.5678

Return CByte(nTest) // returns 126

Notes

  • CByte rounds expressions. When the fractional part is exactly 0.5, CByte always rounds to the nearest even number.
  • CByte uses the locale settings to convert exp to byte.
  • When exp cannot be converted to a byte (0-255), a runtime error is generated.