Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
COLOR Statement Details
◄Summary► ◄Details► ◄Example► ◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
Syntax 1: Screen Mode 0 (Text Only)
COLOR [foreground&] [,[background&] [,border&]]
Syntax 2: Screen Mode 1
COLOR [background&] [,palette%]
Syntax 3: Screen Modes 4, 12, 13
COLOR [foreground&]
Syntax 4: Screen Modes 7, 8, 9, 10
COLOR [foreground&] [,background&]
Usage Notes (General)
■ References to the COLOR statement are not allowed when forms are
showing and cause Visual Basic to generate an error. Use the HIDE method
to hide any visible forms or controls before executing this statement.
See: ◄HIDE Method►
■ The available color attributes for COLOR depend on your graphics
adapter and the screen mode set by the most recent SCREEN statement.
See: ◄Adapters and Displays► ◄SCREEN Statement►
■ Visual Basic generates the error message "Illegal function call" if you
attempt to either:
• Specify COLOR statement arguments outside allowable ranges
• Use the COLOR statement in screen modes 2, 3, or 11
■ The foreground can be the same color as the background, making both
characters and graphics invisible.
■ The default background color is black for all display hardware
configurations and all screen modes. This background is produced by the
default display color of 0 associated with the background color
attribute of 0.
■ With an EGA, VGA, or MCGA installed, the PALETTE statement gives you
flexibility in assigning different display colors to the attribute
color ranges for the foreground, background, and border colors.
See: ◄PALETTE Statement►
Usage Notes (Screen Mode 0, Text Only)
■ The foreground color value must be an integer expression between 0 and
31, inclusive. Sixteen colors can be selected with the integers 0-15.
A blinking version of a color is specified by adding 16 to the color
number. For example, a blinking color 7 is equal to 7+16, or 23.
See: ◄Color Attributes and Values (SCREEN)►
■ The background color value is an integer expression between 0 and 7,
inclusive, and is the color of the background for each text character.
Blinking background colors are not supported.
■ The border color, which fills the screen area outside the text area, is
an integer expression between 0 and 15, inclusive.
■ The border& argument has no effect with:
• IBM Enhanced Graphics Adapter (EGA)
• IBM Video Graphics Array adapter (VGA)
• IBM Multicolor Graphics Array adapter (MCGA)
• Forms
Usage Notes (Screen Mode 1)
■ In screen mode 1, a COLOR statement overrides PALETTE statements that
were executed previously. See: ◄PALETTE Statement►
■ The background color value must be an integer expression between
0 and 3, inclusive.
■ The palette% argument is an integer expression with an odd or even
value, between 0 and 255, inclusive. An even value makes available one
set of three default foreground colors; an odd value makes available
a different default set.
■ The following Visual Basic code defines the two default sets of colors
in terms of EGA PALETTE statements:
' Definition of the even palette-number set
COLOR ,0 ' In screen mode 1, an even palette number
' is equivalent to next three EGA PALETTE
' statements:
PALETTE 1,2 ' EGA Attribute 1 = color 2 (green)
PALETTE 2,4 ' EGA Attribute 2 = color 4 (red)
PALETTE 3,6 ' EGA Attribute 3 = color 6 (yellow)
' Definition of the odd palette number set
COLOR ,1 ' In screen mode 1, an odd palette-number
' is equivalent to:
PALETTE 1,3 ' EGA Attribute 1 = color 3 (cyan)
PALETTE 2,5 ' EGA Attribute 2 = color 5 (magenta)
PALETTE 3,7 ' EGA Attribute 3 = color 7 (white)
Usage Notes (Screen Mode 4)
■ With screen mode 4, the argument foreground& is an integer expression
between 0 and 15, inclusive. This expression sets the display color
associated with color attribute 1 only. The screen background color is
fixed as black.
Usage Notes (Screen Modes 7, 8, 9, 10)
■ The foreground (line-drawing) color is a color attribute.
■ The background (screen) color is a display color.
Usage Notes (Screen Mode 11)
■ In screen mode 11, you can set both the foreground and background colors
by assigning a color to attribute 0 with a PALETTE statement.
See: ◄PALETTE Statement►
Usage Notes (Screen Modes 12, 13)
■ With screen modes 12 and 13, the argument foreground& is a color
attribute.
■ In screen modes 12 and 13, you can set the background color by assigning
a color to attribute 0 with a PALETTE statement. For example, to make
the background color 8224 (olive green), use the following PALETTE
statement:
PALETTE 0,8224
■ To make the background color bright red-violet, use:
PALETTE 0,4128831
See: ◄PALETTE Statement►