Or with only one button:
Dim StartTime As Date
'
Private Sub cmdStart_Click()
if StartTime = 0 then
StartTime = Now
cmdStart.caption = "Stop Timer"
else
MsgBox DateDiff("s", StartTime, EndTime)
StartTime = 0
cmdStart.caption = "Start Timer"
end if
End Sub
If course you can store the difference in a variable and use it elsewhere, too.
WaltP
Posting Sage w/ dash of thyme
10,507 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
Its OK to use Single Command Button,
but not OK to Check for StartTime = 0 .
As StartTime =0 means 12:00:00 AM.
What If the user clicks Stop At exactly that time?
Good point. I'm used to C where the time returns time from a specific date. I forgot VB's time is 24hrs.
Good solution checking the caption... :)Well.. I'am not trying to Argue with the moderator, but trying to tell one of the rare possibilities.You can correct any moderator when they are wrong. We're just as human as you. Well some mods are. There are a couple I'm not so sure about :confused:
WaltP
Posting Sage w/ dash of thyme
10,507 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944