# QBColor
{: .no_toc }

Returns a **Long** representing the RGB colour code corresponding to the specified colour number.

Syntax: **QBColor(** *color* **)**

*color*
: *required* An **Integer** in the range 0--15.

The *color* argument has these settings:

| Number | Colour | Number | Colour |
|--------|--------|--------|--------|
| 0 | Black | 8 | Gray |
| 1 | Blue | 9 | Light Blue |
| 2 | Green | 10 | Light Green |
| 3 | Cyan | 11 | Light Cyan |
| 4 | Red | 12 | Light Red |
| 5 | Magenta | 13 | Light Magenta |
| 6 | Yellow | 14 | Light Yellow |
| 7 | White | 15 | Bright White |

![The sixteen QBColor colours, from 0 Black to 15 Bright White, each a swatch with its number and name](/Reference/Default/VBA/Information/Images/QBColor.png){:width="753" height="205"}

The *color* argument represents colour values used by earlier versions of Basic --- Microsoft Visual Basic for MS-DOS and the QuickBASIC compiler. Starting with the least-significant byte, the returned value specifies the red, green, and blue components used to set the corresponding colour in the RGB system, exactly as if [**RGB**](/tB/Modules/Information/RGB.md) had been called with those components.

### Common Errors

| Error | When |
|---|---|
| [5 (`&H5`)](/Reference/Run-time-Errors.md#5), *Invalid procedure call or argument* | *color* is outside 0 to 15, after rounding |
| [94 (`&H5E`)](/Reference/Run-time-Errors.md#94), *Invalid use of Null* | *color* is **Null** |

### Example

This example uses **QBColor** to set a form's background colour from a numeric colour code.

```tb check_build
Sub ChangeBackColor(ByVal ColorCode As Integer, ByVal MyForm As Form)
    MyForm.BackColor = QBColor(ColorCode)
End Sub
```

### See Also

- [RGB](/tB/Modules/Information/RGB.md), [RGBA](/tB/Modules/Information/RGBA.md) functions
- [TranslateColor](/tB/Modules/Information/TranslateColor.md) function
