![]() |
|
|
Manipulating the Different Controls and Components In this section, we'll take a closer at the many controls available in Visual Basic. Most of these are located in the Tool Box and can be easily drawn on your forms. Combo Boxes and List Boxes Frames, Option Buttons and Check Boxes Using the Timer Control Adding Additional Controls to your Tool BoxUsing the Timer Control The Timer Control can be used to determine when to execute a block of code or whether to set properties of controls at fixed time intervals. Basically, you set the interval for your timer (after you draw it on your form), and then the specified code within the Timer event of your Timer will be invoked after the selected interval. The interval property is measured in milliseconds. The allowed values are from 1 to 65,535 (which is about 1 minute). To simply display an autorefreshing clock on your form, you can set the interval to 1000 (1 second) and display the current time in a label in the Timer event. First, draw
a label on your form and call it MyLabel. Second,
place the Timer control MyLabel.Caption = Time The caption of the label MyLabel will be updated with the current time of your system every second. Note that we are using the Time function here to get the current time. You can also use the Timer to display a message box every 30 seconds warning the user that the time is approaching, for example, the start of a football match. |