-
Measure Time Remaining Of A Process
Hi All
I have a but of trouble and would like to know how to measure time remaining of a process, like copying a large file or any other lenghty process.
For example:
FolderCount = Text1.text
For I = 1 to FolderCount
Label1.caption = <time remaining>
MkDir "Test Folder" + " " + FolderCount
Next I
Suppose you have many folders to create, then how can I display, in a label, the time to completethe entire operation, during the loop, in minutes and seconds? I want to have the process count down in minutes and seconds (maybe hours too) from how long it will take initially to zero time at the end. For example the Windows copy dialog that counts down the time to copy file(s) from a start time the process will take to completion of zero seconds.
Someone suggested I should use the following code, however it seems to count up or just display to total extimated time during the entire process and does not reach zero at the end:
Dim StartTime As Date, ElapsedTime As Date, EstimatedTotalTime As Date, EstimatedTimeRemaining As Date
Dim TimePerIteration As Double
Dim I As Long, FolderCount As Long
FolderCount = Text1.Text
StartTime = Date + Time
For I = 1 To FolderCount
ElapsedTime = (Date + Time - StartTime)
TimePerIteration = ElapsedTime / I
EstimatedTotalTime = CDate((FolderCount * TimePerIteration))
EstimatedTimeRemaining = EstimatedTotalTime - ElapsedTime
Label1.Caption = "Estimated Time Remaining = " & EstimatedTimeRemaining
DoEvents
MkDir "Test Folder" & " " & I
Next I
Any help with this will be truly appreciated.
Thankx a million
-
There's no way to accurately count down in minutes and seconds; how do you determine how long it will take to copy each folder? The Windows copy dialog merely displays an estimate; have you noticed that sometimes it counts up? (See http://blogs.msdn.com/oldnewthing/ar.../06/47937.aspx for more information.)
You can, however, display the percent complete: Calculate the total number of files to be copied. After every, say, 10 files copied, display the value of (FilesCopied / TotalFilesToCopy) * 100 in the label.
Phil Weber
http://www.philweber.com
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
-
Measure Time Remaining Of A Process
Phil Weber
Thank you for your reply.
I guess I will measure the time (with GetTickCount) 1 to 2 in For I = 1 to TotalNumber and then multiply the result with TotalNumber - 1. Let’s see
what happens, I am just interested in a vague result.
Have a good day
Cheerio
Francois
Similar Threads
-
By chan_fookmun in forum .NET
Replies: 0
Last Post: 05-11-2005, 12:13 AM
-
By ecaslake in forum .NET
Replies: 6
Last Post: 04-20-2005, 10:23 AM
-
By Dennis in forum VB Classic
Replies: 10
Last Post: 02-15-2001, 04:52 AM
-
By JeffM in forum Database
Replies: 2
Last Post: 02-06-2001, 06:21 PM
-
By Saheb Bothe in forum Web
Replies: 1
Last Post: 05-08-2000, 06:43 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|