Timer in Visual Basic .NET

Tags: VB.NET, VB 2008, VB 2010, VB 2012, VB 2013

To use the timer control:
First add the timer control to your Form:

Drag it from the ToolBox Visual Basic .net Timer to your form

You can change the properties of Timer as needed, right click on it and click on Properties:

If you set Enabled to True, Timer will start ticking as soon as the form loads. Default is False.

Interval: as described: The frequency of Elapsed events in milliseconds. 1000 = 1 second.

You can start the timer in your code. If you want to start the timer when you click a button for example:

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) _
 Handles Button1.Click
    End Sub
To stop it:

To do things while timer is ticking, double click on the timer control, it should add the Timer.Tick event for you:

Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) _
 Handles Timer1.Tick
' Add your code here
    End Sub

You can also adjust the intervel frequency using a textbox:
Add a textbox, label and a button to your form:

Double Click the button and add the following code to the button click event:

Timer1.Interval = TextBox1.Text

Please check out the following tutorials to see advanced use of the timer:
StopWatch Tutorial
Analog Clock Tutorials

Share This

Home | About | Contact | Privacy Policy

Copyright visual-basic-tutorials.com 2018 - All Rights Reserved.