# RGB
{: .no_toc }

Returns a **Long** representing an RGB colour value.

Syntax: **RGB(** *red* **,** *green* **,** *blue* **)**

*red*
: *required* An **Integer** in the range 0--255 representing the red component of the colour.

*green*
: *required* An **Integer** in the range 0--255 representing the green component of the colour.

*blue*
: *required* An **Integer** in the range 0--255 representing the blue component of the colour.

Application methods and properties that accept a colour specification expect a number representing an RGB colour value: the relative intensity of red, green, and blue that produces a particular shade. The value of any argument that exceeds 255 is treated as 255.

The following table lists some standard colours and the red, green, and blue values they include:

| Colour | Red | Green | Blue |
|--------|-----|-------|------|
| Black | 0 | 0 | 0 |
| Blue | 0 | 0 | 255 |
| Green | 0 | 255 | 0 |
| Cyan | 0 | 255 | 255 |
| Red | 255 | 0 | 0 |
| Magenta | 255 | 0 | 255 |
| Yellow | 255 | 255 | 0 |
| White | 255 | 255 | 255 |

### Common Errors

| Error | When |
|---|---|
| [5 (`&H5`)](/Reference/Run-time-Errors.md#5), *Invalid procedure call or argument* | *red*, *green* or *blue* is negative, after rounding |
| [94 (`&H5E`)](/Reference/Run-time-Errors.md#94), *Invalid use of Null* | *red*, *green* or *blue* is **Null** |

### Example

This example uses **RGB** to construct several colour values.

```tb check_build
Dim Red As Long, RGBValue As Long, I As Long
Red = RGB(255, 0, 0)                  ' Pure red.
I = 75
RGBValue = RGB(I, 64 + I, 128 + I)    ' Same as RGB(75, 139, 203).
```

### See Also

- [RGBA](/tB/Modules/Information/RGBA.md) function
- [RGB_R](/tB/Modules/Information/RGB_R.md), [RGB_G](/tB/Modules/Information/RGB_G.md), [RGB_B](/tB/Modules/Information/RGB_B.md) functions
- [QBColor](/tB/Modules/Information/QBColor.md), [TranslateColor](/tB/Modules/Information/TranslateColor.md) functions
