Solved

Determine how long someting runs

Posted on 2015-01-11
14
63 Views
Last Modified: 2015-01-12
I have a vb6 Keno game that runs unattended 4000 times an stops
How can i determine the length of time it runs ?
0
Comment
Question by:isnoend2001
  • 7
  • 7
14 Comments
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40543631
Please see my article on the subject.
0
 

Author Comment

by:isnoend2001
ID: 40543638
Thanks Marty, but i think that's a little overkill
Don't need that much accuracy
example :
3hours, 20 minutes is close enough
0
 

Author Comment

by:isnoend2001
ID: 40543640
would this be accurate

Dim StartTime as date ?
dim EndTime as date ?
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 46

Expert Comment

by:Martin Liss
ID: 40543641
It depends on the desired accuracy you desire but the methods I describe are much more accurate.
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40543644
Thanks Marty, but i think that's a little overkill
Don't need that much accuracy
example :
3hours, 20 minutes is close enough
The  StartTime and End Time is all you need.
0
 

Author Comment

by:isnoend2001
ID: 40543649
Would this work ?
Dim mtimStartTime as date
Dim mtimEndTime as date
mtimStartTime = Now
mtimEndTime = Now
lblTime = mtimEndTime - mtimStartTime
0
 
LVL 46

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 40543659
No. You'll need to do something like this

Dim mtimStartTime As Date
Dim mtimEndTime As Date
mtimStartTime = Now
mtimEndTime = Now
lblTime = DateDiff("m", mtimEndTime, mtimStartTime)

Open in new window


which will give the number of minutes. You could also do some math to convert it to hours and minutes before displaying in the label.
0
 

Author Closing Comment

by:isnoend2001
ID: 40543667
Thanks just what i needed
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40543671
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
0
 

Author Comment

by:isnoend2001
ID: 40544399
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 ?
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40544663
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".
0
 

Author Comment

by:isnoend2001
ID: 40544938
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
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40544994
My apologies. "m" is month and "n" is minutes. The dates were also backward so

lblTime = DateDiff("n", mtimStartTime, mtimEndTime)
0
 

Author Comment

by:isnoend2001
ID: 40545325
Thanks, that works
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VBA open file from excel cell 4 44
Help me. 3 60
Zip Folders Using Chilkat Routines 1 58
Formula problem with Excel attachment 6 39
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question