Make your own free website on
Write Your First Visual Basic Program

Lesson 3
Tutorials - Page 1 - Page 2 - Page 3 - Page 4 - Page 5 - Page 6 - Page 7 - Page 8 - Page 9 - Page 10 - Page 11 - Page 12 - Page 13

Setting the BackColor Property
You can set the BackColor property at run-time in 2 ways.

Way 1: Using the Color's numeric value
Every color has numeric value.
You can simply assign this value to the BackColor property.

For example, The numeric value of the red color is &H000000FF&
If you want to set the Form BackColor property to red,
use the following code:

Command1.BackColor = &H000000FF&

You can find what is the numeric value of every
color by making the following simple steps:

Click on the BackColor property arrow button
in the properties window (Figure 10).

Figure 10

Then click on the Palette Tab (Figure 11).

Figure 11

Select your desirable color (Figure 12).

Figure 12

The color value will be displayed in the BackColor Property cell (Figure 13).

Figure 13

And once again, if you setting a Command Button's color,
don't forget to set its Style property to 1 - Graphical.

To learn the second way, you'll have to learn
a little bit about Constants.
All of this in the next page...

Back  Forward