Visual Basic for Applications Reference

RGB Function

See Also    Example    Specifics

Returns a Long whole number representing an RGB color value.

Syntax

RGB(red, green, blue)

The RGB function syntax has these named arguments:

Part Description
red Required; Variant (Integer). Number in the range 0255, inclusive, that represents the red component of the color.
green Required; Variant (Integer). Number in the range 0255, inclusive, that represents the green component of the color.
blue Required; Variant (Integer). Number in the range 0255, inclusive, that represents the blue component of the color.

Remarks

Application methods and properties that accept a color specification expect that specification to be a number representing an RGB color value. An RGB color value specifies the relative intensity of red, green, and blue to cause a specific color to be displayed.

The value for any argument to RGB that exceeds 255 is assumed to be 255.

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

Color Red Value Green Value Blue Value
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