-1

I'm currently trying to install timer in VBA - I'm working on a quizz.

There are several questions to answer. What I would I like to know is the time that someone spends answering each question. So the timer should start every time someone clicks on question, then stop when someone clicks on question 2 and start again instantly.

Jean-François Corbett
  • 37,420
  • 30
  • 139
  • 188

2 Answers2

0

OnClick events. Just use a DateDiff to calculate the time spent. Of course, they'd have to click a button to begin the exam, or open the form that contains the exam, so there's an initial reference point. But it should only take a few milliseconds to write that timestamp to a table and then calculate the difference each time the button is clicked.

Johnny Bones
  • 8,786
  • 7
  • 52
  • 117
  • Dim running As Boolean Sub Clock() running = Not (running) Do While running = True DoEvents Range("A1") = Now Loop End Sub That's the last macro i've tried. But it gave me the time and not a count. – Alex Dalou Jun 06 '13 at 21:16
  • I was talking about putting timestamps into a table to signify the start time of each click. Then, once you have all the start times logged, you can run a report or output the data to the form by using DateDiff. I'm not really clear whether you want this data to be able to report on, or if you want it to display on the screen for the person taking the quiz. – Johnny Bones Jun 07 '13 at 14:37
0

You can use the Timer function. It will give you a precision up to 1/1000 of a second:

Dim myTime as variant
myTime = Timer
... 
Debug.Print "Process duration", Timer - myTime
Philippe Grondier
  • 10,900
  • 3
  • 33
  • 72