Question:
I need help Making A Visual basic timer?
steve
2009-06-24 12:21:33 UTC
I'm designing a database in Microsoft access 2003 that is going to be used to capture elapsed times. I need to use two stopwatches that run independantly of eachother and am having trouble with the code I'm using. I am able to get one stopwatch to work fine, but when I add the seccond one the start/stop buttons work with both timers. Help please?
Five answers:
anonymous
2009-06-24 12:37:12 UTC
Further to what fireop said. If you place timers on your form (the user won't see it then you can add handlers to track time for you.



If you double click the timers the handlers will be added automatically. In the handler you can update the elapsed time separately and show it in a label or text box. You can have a button below each time display to start/stop the timers - you can change the label based on the action that is happening.



When starting a timer you set its interval (it is specified in milliseconds to 1000 will get you a 1 second tick) and then you set its enabled property to true.



To stop the time just set its enabled property to false.



Email me if you need help.
BillD
2009-06-24 13:49:39 UTC
If you are using the timers built into MS-Access forms then I suggest using 2 forms and embedding one within the other so it appears as one form to the user. This way you can control the "OnTimer" and "Timer Interval" properties indepndently for each form.
?
2009-06-25 06:13:52 UTC
Drop two Timer Control from ToolBox to your Form window.

and also drop two command button

Set inverval property of timer control to 1000.



Private Sub Command1_click

if timer1.enabled=true then ' Timer is running

timer1.enabled=false 'Stop timer

else ' Timer is not running

timer1.enabled=true 'Start Timer

end if

end sub



Private Sub Command2_click

if timer2.enabled=true then ' Timer is running

timer2.enabled=false 'Stop timer

else ' Timer is not running

timer2.enabled=true 'Start Timer

end if

end sub
FireFop
2009-06-24 12:27:33 UTC
Why don't you just use the basic timer control (drop 2 in there) and control them with different buttons?
ITConsulting
2009-06-24 12:49:53 UTC
Create an array of stopwatches sub1 and sub2 and filter events based on selection.

Contact me or any question


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