Question:
Timer in VB.NET?
Froskoy
2007-05-15 14:28:27 UTC
Your all legends in answering my quesitons so far so thanks in advance... here we go!

Right, I've got this app and I want a 20 second timer followed by which an integer variable is reset to zero. I'm using Visual Studio 2005 Visual Basic.

Thanks loads. I'd appreciate it if you could give me the code. Thanks.
Four answers:
gcos7
2007-05-15 14:59:30 UTC
First you should click view and click the toolbox so that the various controls, etc., show on the left side of your screen.



In the toolbox, scroll down until you see the "Data" section. The timer is listed there. Just drag it onto your application.



Now you need to decide when you are going to initialize the timer and put it in the appropriate code section. You do this by setting the "timername".interval to the number of milliseconds you want to elapse before the timer triggers the event. Then you need to enable the timer.



When the interval elapses for an enabled timer, the event triggers the code you put in the "timername".tick section of code found on the code page for the form. So, in your case, you would reset your variable to zero.



Remember to either disable the timer to avoid multiple triggering, or just reset the interval and be sure the timer is still enabled.
anonymous
2016-11-23 20:25:23 UTC
You wager your hind quarters. that is now 5:50 EDT, the race starts off in 10 minutes on ESPN2. EDIT: merely began. motive force introductions: Cale Yarborough Jack Ingram L.D. Ottinger Harry Gant Larry Pearson (David's son) Terry Labonte Sterling Marlin David green Jimmy Spencer Phil Parsons Rusty Wallace (previous colors) Junior Johnson (wrecked in prepare, repaired, will race) %. vehicle, Bobby Allison Grand Marshall: David Pearson Ned and Dale Jarrett in the sales area
superheroboy
2007-05-15 15:17:05 UTC
Dim timeOut As DateTime = Now.AddMilliseconds(20000)

Do

Application.DoEvents() 'This will loop for 20 seconds

Loop Until Now > timeOut

myInt=0 'Reset integer variable to zero
anonymous
2007-05-17 09:25:40 UTC
In the sub you want to use it:

Dim Timer1 as new timer()

Timer1.Interval = 0 'Time

addhandler timer1.tick, addressof timer1_start

timer1.start



Then in the new timer1_start sub:

private sub timer1_start(ByVal sender As System.Object, ByVal e As System.EventArgs)

'Commands, e.g. Status.Text = Date.Now.ToString()

End Sub


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...