Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I show elasped time?

Status
Not open for further replies.

bigracefan

Programmer
Apr 2, 2002
304
US
Merry Christmas Y'all,

While I'm inserting records into excel I'd like to show the elasped time. I've set up a progessbar to show the progression already. I would love to do time remaining but I'm not sure how to go about it. 27 records are inserted every 10 seconds or 162 every minute. I could probably show an estimated total time using this but I'd really like to show either elasped time or time remaining. Any ideas?

Thanks,

Pete
 
Use the Timer to figure elapsed time.

When your process starts, set a variable like this:

X = Timer

As the process is working, you can figure the elaped time ( in seconds ) from start by doing this:

Debug.Print "Elapsed Time " & Int(Timer - X)

Or instead of using Debug.Print, you can update a label or whatever. You may need a DoEvents during the update to get it to show.

Robert
 

Elapsed time is simple as using a timer and a label, ... well you don't even need a timer. You could also check out the GetTickCount API but that may be a little bit of overkill for what you need. Get the current time as you enter your loop for processing and every so often get the time again and use the datediff function.

Good Luck

 
The "timer" function is a little easier to use (no dateDiff required) since it returns the number of seconds since midnight.... -----------------------------------------------------------------
"The difference between 'involvement' and 'commitment' is like an eggs-and-ham breakfast: the chicken was 'involved' - the pig was 'committed'."
- unknown

mikewolf@tst-us.com
 
You just need to make sure to account for crossing midnight and having Timer go back to zero (if this ever gets used at night).

As for time remaining, you need to same similar kind of operation. You know how many records you're going to insert, so every now and then, you calculate how long it took to do what you've done so far and then multiply that by what's left. So, after 10% of the records are processed, you can multiply that amount of time by 9 to get how long it'll take to do the remaing 90%, etc.
 
im with thevampire
since no-ones given you some code so far, figure i might as well...

private sub form_load()
StartTime=now
timer1.interval=yourInterval
end sub

private sub timer1_timer()
ThisTime=now
elapsedTime=datedif(s,StartTime,ThisTime)
'display elapsed time as you wish
end sub

hope this is of use

merry christmas back at ya
 
Easy men

Private sub iTimerProc()
bTimer=timer

'Put code here to do something

eTime=timer

uTime=eTime-bTime

'uTime is the time used

end sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top