BASIC Language Reference Manual > Command and Function Reference >



Changes the text background color that will be used by subsequent PRINT and INPUT statements.


TEXTBGCOLOR red intensity, green intensity, blue intensity

Remarks and Examples

The TEXTBGCOLOR command changes the color that will be used for the background of the rectangles placed behind text characters that are written to the screen. When the text background color is set, all subsequent text commands use that background color, until you change the background color again.

A color is specified as a set of three component primary color intensity values: a value for the intensity of the red component, a value for the intensity of the blue component, and a value for the intensity of the green component. Intensity values can range between 0 (no color) and 255 (maximum intensity). This means that there are 256 * 256 * 256 = 16,777,216 possible colors.

For example, to set the background color to yellow, use a value of 255 for the intensity of red and green, and use a value of 0 for the intensity value of blue.

To change the text foreground color, use command TEXTCOLOR. Note that it is possible to set a combination of foreground and background colors that makes text unreadable.

There is currently no way to make the background color "transparent"; writing text will always overwrite any graphics or text that was in that position previously.


100 TEXTBGCOLOR 50, 100, 50 : REM Set text background color to forest green
110 TEXTCOLOR 255, 255, 0 : REM Set text foreground color to yellow
120 CLS : REM Clear screen
130 PRINT "Here is some text with yellow text on a forest green background."
140 TEXTCOLOR 50, 230, 230
150 TEXTBGCOLOR 30, 30, 30
160 PRINT "Here is some sea green text on a dark gray background."

The color white can be obtained with values 255, 255, 255. The color black can be obtained with values 0, 0, 0.


Copyright 2006-2012, Kevin Matz, All Rights Reserved.