tags:

views:

34

answers:

4

Hi, How can I use timer in vb.net? I want to repeat a statement after every 5 seconds but timer event offers only timer_tick() and timer_disposed()

In which event I can write my required code? Thanks Furqan

A: 

The timer_tick method is called in time-interval You set. Your code should go there.

Turek
+1  A: 

You will want to use the Tick event. When the Timer is enabled, it will be raised on the interval defined by the Interval property.

Fredrik Mörk
A: 

You should handle the Timer's Tick Event and write in the required statement which should repeat every 5 seconds there. Have a look at the following example: http://msdn.microsoft.com/en-us/library/system.windows.forms.timer.tick.aspx

Tim Schmelter
+1  A: 

You could write your event in the timer_tick().

It's worth noting that your timer tick is in Milliseconds (ms) so you'll need to set its property to 5000 for 5 seconds.

You'll also need to start the timer (timer1.start) (you can do this on form load if you want the action to start from when the form is first loaded) and then put your loop in the timer_tick() section :)

Have a look here for a rudimentary explanation:

http://articles.techrepublic.com.com/5100-10878_11-6150796.html

Wes Price