Lesson 3: Working with Control Properties.
Previous Lesson<< [Home ] >>Next Lesson
|
3.1 The Control Properties Before writing an event procedure for the control to response to a user's input, you have to set certain properties for the control to determine its appearance and how it will work with the event procedure. You can set the properties of the controls in the properties window at design time or at runtime.
You can also change the properties of the object at runtime to give special effects such as change of color, shape, animation effect and so on. For example the following code will change the form color to yellow every time the form is loaded. VB2008 uses RGB(Red, Green, Blue) to determine the colors. The RGB code for yellow is 255,255,0. Me in the code refer to the current form and Backcolor is the property of the form's background color. The formula to assign the RGB color to the form is Color.FormArbg(RGB codes).
You may also use the follow procedure to assign the color at run time.
Both procedures above will load the form with a yellow background as follows:
Here are some of the common colors and the corresponding RGB codes. You can always experiment with other combinations, but remember the maximum number for each color is 255 and the minimum number is 0.
The following is another program that allows the user to enter the RGB codes into three different textboxes and when he/she clicks the display color button, the background color of the form will change according to the RGB codes. So, this program allows users to change the color properties of the form at run time.
The code
|
Figure 3.1
|
Previous Lesson<< [Home ] >>Next Lesson
Copyright® Dr.Liew Voon Kiong Contact: admin@vbtutor.net Privacy Policy