Qbasic Tutorial for beginners and children (Under Construction)


Chapter 9

Using colours

The COLOR statement is used to set the screen display colours.

It can be used in the following ways:

To modify both the foreground and the background colour use:

COLOR [foreground colour] , [background colour]

To modify the foreground colour only, use:

COLOR [foreground colour]

To modify both the background colour only, use:

COLOR , [background colour]

The foreground colour and the background colour are represented by numbers

The table below Below list the colours and their corresponding numbers.

Number Colour Number Colour
0 Black 8 Grey
1 Blue 9 Light Blue
2 Green 10 Light Green
3 Cyan 11 Light Cyan
4 Red 12 Light Red
5 Magenta 13 Purple
6 Brown 14 Yellow
7 White 15 Light White

 

The following examples illustrate how to use the COLOR statement:

Example 1: Printing in red over blue
Program Code

COLOR 14, 1

PRINT "This text is in Yellow over Blue"

Output on Screen

 This text is in Red over Blue

 

 

 

If you want to get the whole background in blue use the CLS statement after setting the colours:

Example 2
Program Code

COLOR 4, 1

CLS

PRINT "This text is in Yellow over Blue"

Output on Screen

 This text is in Red over Blue

 

 

 

 

You should be careful about the use of colours. Some colour matching are not pleasant to the eyes.

[ Previous Next ]


pages viewed since January  19 2002