Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set Timer

Status
Not open for further replies.

Drol

Instructor
Mar 13, 2002
25
0
0
GB
I need to time a test for 30 mins, how to I get the timer to run from a Cmd Button?
 
To set a timer to run on CMDButton Click

Timer1.Enabled = true
 
Private Sub Command1_Click()
' Timer code will fire once a second. Interval is milliseconds
Me.Timer1.Interval = 1000
End Sub
 
Don't forget that the timer can only be set up to 65535 max (a little over a minute).
try this:

In the Form load (or wherever you want to start the timer):
Code:
Timer1.Interval = 60000 ' 1 minute
Timer1.Enabled = True
and for the Timer event:
Code:
Private Sub Timer1_Timer()
Static lngCounter As Long
lngCounter = lngCounter + 1
If lngCounter = 30 Then
MsgBox "30 mins is up"
Timer1.Enabled = False
lngCounter = 0
End If
End Sub
Let me know if this helps
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'There are 10 kinds of people in the world: those who understand binary, and those who don't.'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top