Results 1 to 7 of 7

Thread: [VB] Estimated Time Till Completion

Threaded View

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2001
    Posts
    525

    Lightbulb [VB] Estimated Time Till Completion

    I came up with this method of figuring out how long it'll take for my program to run through a ton or records (up to 500K). It works pretty well I think, but I'm interested in seeing what other ways people can come up with.

    iFileNR = Number of Records In File

    VB Code:
    1. 'Timer Refresh
    2. Dim RCTimer As String
    3. Dim RCTimerOLD As String
    4. Dim SecondsLeft As String
    5. Dim aveDiff As Long
    6. Dim aveDiffCount As Integer
    7. Dim iTotalTime As Integer
    8.  
    9. 'Progress Bar Refresh
    10. Dim pbPercent As String
    11. Dim pbTime As String
    12. Dim pbGBW As Integer
    13. Dim wHalf As Integer
    14.  
    15. Private Sub SampleFunction()
    16.  
    17. RC = 0
    18.  
    19. Do Until EOF(1)
    20.   UpdateProgressBar RC 'Call Function
    21.  
    22.   Seek #1, ((RC * RecordLength) + 1)
    23.   Get #1, , Record
    24.  
    25.   RC = RC + 1
    26.   RCTimer = RC
    27. Loop
    28.  
    29. End Sub
    30.  
    31. Private Sub tmrProgressBar_Timer()
    32.     Difference = Val(RCTimer) - Val(RCTimerOLD)
    33.     aveDiff = aveDiff + Difference
    34.     If aveDiff <> 0 Then aveDiffCount = aveDiffCount + 1
    35.     Difference = Round((aveDiff / aveDiffCount), 0)
    36.    
    37.     LeftOvers = iFileNR - RCTimer
    38.     IntervalsLeft = LeftOvers / Difference
    39.     TimeLeft = IntervalsLeft * tmrProgressBar.Interval
    40.     tmpSecondsLeft = TimeLeft / 1000
    41.     SecondsLeft = Round(tmpSecondsLeft, 0)
    42.     RCTimerOLD = RCTimer
    43. End Sub
    44.  
    45. Private Sub UpdateProgressBar(RC As Long)
    46.    
    47.     'Time Remaining Display
    48.     If (Val(SecondsLeft) Mod 60) < 10 Then FormatedSeconds = "0" & (Val(SecondsLeft) Mod 60) Else FormatedSeconds = (Val(SecondsLeft) Mod 60)
    49.     NewTime = (Val(SecondsLeft) \ 60) & ":" & FormatedSeconds
    50.    
    51.     pbTime = NewTime
    52.        
    53. End Sub
    might help if I had the everything that's involved with it posted
    Last edited by jsun9; Dec 22nd, 2003 at 03:00 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
  •  



Click Here to Expand Forum to Full Width