Microsoft Office Tutorials and References
In Depth Information
Why are these colors the only ones with constants assigned to them? The reason lies in how
colors are created on a computer. You probably encountered the color wheel sometime, prob
ably in school, and you learned that you can combine red, blue, and yellow pigments to create
any color you want. That’s true for pigments (usually paint or ink), but it’s not true when
you’re working with light. When you want to create colors using light, you operate with these
three primary colors: red, green, and blue.
The difference between working with pigments and working with light is captured in the
names of the two color systems: subtractive color , which refers to pigments, and additive color ,
which refers to light. In the subtractive color system, you begin with white (the absence of
color ) and, through the use of pigments, “subtract” colors by blocking them out with your
paint. If you mix equal amounts of the primary colors (red, yellow, and blue) you’ll get black
because you’ve subtracted all of the colors. In the additive color system, by contrast, you start
with black (the absence of light ) and add colors to the mix. In the additive color system, add
ing full-intensity red, green, and blue light, you get white light.
Just as you can mix differing amounts of paint to produce unique colors (for example, mix
ing equal amounts of red and yellow makes true orange, whereas putting in more red than
yellow makes a red-orange), you can mix differing amounts of light to create distinct colors
on your computer. The Microsoft Windows operating system recognizes 256 intensities for
each primary color (red, green, and blue). An intensity of 0 means that none of that light is
added to the color of a pixel (a dot on your monitor screen), and an intensity of 255 means
that the maximum amount of that color is added.
Note A pixel is actually made up of three dots: one that emits red light, one that emits
green light, and one that emits blue light.
To define a color using a mixture of red, green, and blue light, you use the Visual Basic RGB
function, which has this syntax:
RGB( red , green , blue )
In this function, red is the amount of red light to be used, green is the amount of green light to
be used, and blue is the amount of blue light to be used. (Any value over 255 is assumed to be
255.) Table 10-2 lists the RGB values for the eight colors assigned to the VBA color constants.
Table 10-2. The RGB Values of the VBA Color Constants