isnoend2001
asked on
Determine how long someting runs
I have a vb6 Keno game that runs unattended 4000 times an stops
How can i determine the length of time it runs ?
How can i determine the length of time it runs ?
Please see my article on the subject.
ASKER
Thanks Marty, but i think that's a little overkill
Don't need that much accuracy
example :
3hours, 20 minutes is close enough
Don't need that much accuracy
example :
3hours, 20 minutes is close enough
ASKER
would this be accurate
Dim StartTime as date ?
dim EndTime as date ?
Dim StartTime as date ?
dim EndTime as date ?
It depends on the desired accuracy you desire but the methods I describe are much more accurate.
Thanks Marty, but i think that's a little overkillThe StartTime and End Time is all you need.
Don't need that much accuracy
example :
3hours, 20 minutes is close enough
ASKER
Would this work ?
Dim mtimStartTime as date
Dim mtimEndTime as date
mtimStartTime = Now
mtimEndTime = Now
lblTime = mtimEndTime - mtimStartTime
Dim mtimStartTime as date
Dim mtimEndTime as date
mtimStartTime = Now
mtimEndTime = Now
lblTime = mtimEndTime - mtimStartTime
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks just what i needed
You're welcome and I'm glad I was able to help.
In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2014
In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2014
ASKER
Doing Some testing and i always get 0 minutes
Debug.Print mtimStartTime = 1/12/2015 6:40:06 AM
Debug.Print mtimEndTime = 1/12/2015 6:41:02 AM
lblTime = DateDiff("m", mtimEndTime, mtimStartTime) & " minutes"
lblTime displays 0 Minutes
What am i doing wrong ?
Debug.Print mtimStartTime = 1/12/2015 6:40:06 AM
Debug.Print mtimEndTime = 1/12/2015 6:41:02 AM
lblTime = DateDiff("m", mtimEndTime, mtimStartTime) & " minutes"
lblTime displays 0 Minutes
What am i doing wrong ?
It shows 0 because your time is less than one minute and VB truncates the results. If you are interested in under-one-minute accuracy you'll need to do "s" (seconds) ratherthan "m".
ASKER
I was only looking at the minutes so i ran more tests and always get 0
lblTime = DateDiff("m", mtimEndTime, mtimStartTime)
Debug.Print mtimStartTime = 1/12/2015 9:51:24 AM
Debug.Print mtimEndTime = 1/12/2015 10:08:28 AM
lblTime displays 0 Minutes
lblTime = DateDiff("m", mtimEndTime, mtimStartTime)
Debug.Print mtimStartTime = 1/12/2015 9:51:24 AM
Debug.Print mtimEndTime = 1/12/2015 10:08:28 AM
lblTime displays 0 Minutes
My apologies. "m" is month and "n" is minutes. The dates were also backward so
lblTime = DateDiff("n", mtimStartTime, mtimEndTime)
lblTime = DateDiff("n", mtimStartTime, mtimEndTime)
ASKER
Thanks, that works