# CByte
{: .no_toc }

Coerces an expression to a **Byte**.

Syntax: **CByte(** *expression* **)**

*expression*
: *required* Any valid string or numeric expression in the range `0` to `255`.

The return type is **Byte**. Fractions are rounded --- when the fractional part is exactly `0.5`, **CByte** rounds to the nearest even number.

### Common Errors

| Error | When |
|---|---|
| [6 (`&H6`)](/Reference/Run-time-Errors.md#6), *Overflow* | *expression* rounds to a number less than 0 or greater than 255 |
| [13 (`&HD`)](/Reference/Run-time-Errors.md#13), *Type mismatch* | *expression* is a string that does not hold a number (a zero-length string included) |
| [94 (`&H5E`)](/Reference/Run-time-Errors.md#94), *Invalid use of Null* | *expression* is **Null** |

### Example

This example uses the **CByte** function to convert an expression to a **Byte**.

```tb check_build
Dim MyDouble, MyByte
MyDouble = 125.5678          ' MyDouble is a Double.
MyByte = CByte(MyDouble)     ' MyByte contains 126.
```

### See Also

- [CBool](/tB/Modules/Conversion/CBool.md), [CInt](/tB/Modules/Conversion/CInt.md), [CLng](/tB/Modules/Conversion/CLng.md), [CDbl](/tB/Modules/Conversion/CDbl.md), [CSng](/tB/Modules/Conversion/CSng.md), [CStr](/tB/Modules/Conversion/CStr.md), [CVar](/tB/Modules/Conversion/CVar.md) functions
