by ensajg on Fri Jul 31, 2009 4:10 pm
Hi Stephen
thanks for your reply, I am hoping to create a stopwatch that will time a vehicle traveling around a circuit 7 times. I would like to compare each lap time with a cumulative target time to see how early or late the vehicle is so that feed back can be given to the driver to speed up or slow down to finish on time. Timing to a resolution of 1 second is fine as each lap is approx 6 minutes. As you say, it can be done by calculating the difference between 2 recorded times, I was hoping that there might be some way of showing the running time as it increased without having to press a refresh button regularly.
I have seen an excel counting stopwatch with the following VBA code and had wondered if anything equivalent was possible in SpreadCE:
Public stopMe As Boolean
Public resetMe As Boolean
Public myVal As Variant
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Column = 1 Then
If Target.Value = myVal And Target.Value <> "" Then
'Changed
Dim startTime, finishTime, totalTime, timeRow
startTime = Timer
stopMe = False
resetMe = False
myTime = Target.Offset(, 2).Value
Target.Offset(, 1).Select
startMe:
DoEvents
timeRow = Target.Row
finishTime = Timer
totalTime = finishTime - startTime
Target.Offset(, 1).Value = Format(myTime + totalTime, "0.0000") & " Seconds"
If resetMe = True Then
Target.Offset(, 1).Value = 0
Target.Offset(, 2).Value = 0
stopMe = True
End If
If Not stopMe = True Then
Target.Offset(, 2).Value = totalTime
Goto startMe
End If
Cancel = True
End
Else
'Not Changed
stopMe = True
Cancel = True
End If
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
myVal = Target.Value
End Sub
(if you enter a value in column A, and then double click on it the stopwatch will start. to end double click on a blank cell!)
Thanks for your help, I have looked for a suitable laptiming program for Pocketpc3 that will do what I need but without success.
Andy