Visual Basic .NET/Components

Timer in .NETEdit

A timer is one of many components that are non-visible within the runtime of a program. A timer is used to create a sub-like operation that repeats with interval of N milliseconds. The commands within the timer can only run when the timers enabled property is set to true. This can be done by using the following code:

  TimerName.Enabled = True

This code is usually put in a "on click" handler but it can also be used in almost any other handler. To put a timer into your project you must first drag and drop the timer icon from the tool box into your form and then click the timer twice where it is shown under the form to modify the code within it, then you can change the properties accordingly.


Interval


The Interval property is the amount of milliseconds set between each tick this can be changed through the properties panel or be set through the following code

  TimerName.Interval = 1000  'desired integer here

Enabled


The enabled property is the Boolean property in which the status of the timer is set. This can be changed through the properties or through the following code

  TimerName.Enabled = True  'or False
Last modified on 6 July 2013, at 14:14