Click to See Complete Forum and Search --> : How to create a stopwatch?


P81
March 3rd, 2001, 09:23 PM
I want to create a running 'stopwatch' for my game program. the 'stopwatch' time should be shown in a label box. It should be function like "microsoft Minesweeper Game" timer.

CK Dixon
March 4th, 2001, 06:57 AM
put a timer control on your form, set its interval to 1000(milliseconds) set its enabled to false.

Then

private Sub Command1_Click()
Timer1.Enabled = true
End Sub
private Sub Timer1_Timer()
static cnt as Integer
cnt = cnt + 1
Label1.Caption = cnt
End Sub




You cannot make the timer tick more rapidly than once per 55 ms.

P81
March 4th, 2001, 07:49 AM
how do i disable the stopwatch timer with the same command button?

CK Dixon
March 4th, 2001, 08:23 AM
private Sub Command1_Click()
Timer1.Enabled = Not Timer1.Enabled
End Sub