VB.NET Timer control

  • Timer controls are controls that are used to generate periodic events.
  • These controls are called components and they do not appear in a Window at run time.
  • At design time they appear in the component tray below the form in which they are added.
  • You can place a Timer control on the form by drag and drop it from the toolbox. The Timer control looks like as follows:
timer control

Properties of Timer Control


Some of the commonly used properties of Timer Control are listed below in the Table:


timer control

Methods of Timer Control


Some of the commonly used methods of Timer Control are listed below in the Table:


timer control

Events of Timer Control


Some of the commonly used events of Timer Control are listed below in the Table:


timer control

Example

Here is a simple example of Timer control. To understand the use of the Timer control follows the given steps:


  • Add a Label control and Timer control to Form from the ToolBox.
  • Now select the Timer control and open its properties window and change its Enabled property to True.
  • Now click on the Events icon and double click inside the combo box next to Tick event.
  • The Code window will appear. Add the following code in Timer_Tick event handler:
  • Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
    Label1.Text = DateTime.Now.ToString()
    End Sub

  • Now run the application by pressing F5 key. You will get the following output:
  • timer control