ForeColor

The BackColor property returns or sets the background color of an object. The ForeColor property returns or sets the foreground color used to display text and graphics in an object.

Syntax

object.BackColor [= color]

object.ForeColor [= color]

The parts of the BackColor and ForeColor property syntaxes are described in the following table.

Part Description
object An object expression that evaluates to an object.
color A value or constant that determines the background or foreground colors of an object, as described in Settings.

Settings

Visual Basic uses the Microsoft Windows CE operating environment red-green-blue (RGB) color scheme. The settings for color are described in the following table.

Setting Description
Normal RGB colors Colors specified by using the Color palette or by using the RGB function in code.
System default colors Colors specified by system color constants listed in the Visual Basic (VB) object library in the Object Browser. The Windows operating environment substitutes the user's choices as specified in the Control Panel settings.

For all forms and controls, the default settings at design time are:

Remarks

In the Label and Shape controls, the BackColor property is ignored if the BackStyle property setting is 0 (Transparent).

If you set the BackColor property on a Form object, all text and graphics, including the persistent graphics, are erased. Setting the ForeColor property does not affect graphics or print output already drawn. On all other controls, the screen color changes immediately.

The valid range for a normal RGB color is 0 to 16,777,215 (&HFFFFFF). The high byte of a number in this range equals 0; the lower 3 bytes, from least to most significant byte, determine the amount of red, green, and blue, respectively. The red, green, and blue components are each represented by a number between 0 and 255 (&HFF). If the high byte is not 0, Visual Basic uses the system colors, as defined in the user's Control Panel settings and by constants listed in the Visual Basic (VB) object library in the Object Browser.

To display text in the Windows operating environment, both the text and background colors must be solid. If the text or background colors you have selected are not displayed, one of the selected colors may be dithered — that is, comprised of up to three different-colored pixels. If you choose a dithered color for either the text or background, the nearest solid color will be substituted.