Setting the BackColor
Way 2: Using the Colors
First of all, what is Constant?
Constant is a variable
that its value can not be changed.
Constant holds a common used value.
example, the Constant vbRed holds the value
of the red color -
Instead of writing in your
code:Command1.BackColor = &H000000FF&
write:Command1.BackColor = vbRed
The 2 statements above are identical,
vbRed = &H000000FF&
Where are these constants came
Visual Basic automatic declare them
when the program
Imagine it like as the following code is
entered to your program:Dim vbRed As Long
Dim vbBlue As Long
And so on...
But with one exception: You
change the constants value.
For example, the following code is
NOT allowed:vbBlue = 5
There are more Color
constants, a partial list:
vbRed, vbBlue, vbBlack, vbGreen, vbWhite,
You can declare your own constants.
Const MyVariableName = MyVariableValue
example, the following code will declare a const
variable with the name Piano
and the (const) value "abcdef" Const Piano =
After this declaration, the Print
code line will print abcde on the form.
addition, the following code line will not be allowed:Piano =
Because it's been declared as a Const,
and Const value can not
more advanced programming techniques like
statements, go to the Conditional Statements Tutorial