Can someone please help? All I need is to display the elapsed time that it takes for a user to solve a particular puzzle. I am in school and my book doesn't explain it and the MSDN library seems too complicated for what I need. Can some post six-ten lines of code for me please?
I Need A Timer For Vbasic
Collapse
X
-
Hi there,Originally posted by pberardiCan someone please help? All I need is to display the elapsed time that it takes for a user to solve a particular puzzle. I am in school and my book doesn't explain it and the MSDN library seems too complicated for what I need. Can some post six-ten lines of code for me please?
What do you mean by "Can some post six-ten lines of code for me please?"
What should be the contents for those 16 lines? -
That is my question. I dont want this to be a complicated matter at all. The code for this time should be short....that was my point.Originally posted by sashiHi there,
What do you mean by "Can some post six-ten lines of code for me please?"
What should be the contents for those 16 lines?Comment
-
If you record the current system time form Now() into a variable (Eg. StartTime) at the beginning of the task, then to get elapsed time all you need do is subtract the two. ExampleOriginally posted by pberardiCan someone please help? All I need is to display the elapsed time that it takes for a user to solve a particular puzzle. I am in school and my book doesn't explain it and the MSDN library seems too complicated for what I need. Can some post six-ten lines of code for me please?Another option, which may provide a more useful result, is to use the DateDiff function to return the number of a particular time unit between the two values. In other words, it can return the number of seconds, or hours, or whatever.Exampl eCode:' At start of task... Dim StartTime As Date ' Yes I know, but it includes Time as well. :) StartTime = Now() . . . ' When task is finished... Dim Elapsed As DateTime Elapsed = Now() - StartTime
If I got the syntax right, this will return the number of seconds between the start time and the current system time.Code:Elapsed = DateDiff("s", StartTime, Now())Comment
Comment