Solved

Estimated Time and Work Done

Posted on 2007-04-08
6
191 Views
Last Modified: 2010-04-30
I am sorry If I am wrong, But I try tol resolve problem of estimated time and work done as this is my first experience in it.

I have one Progressbar and am trying to show the work done and estimted time.
1) for display work done (Name : PRG_Done)
2) for display estimated time (Name : PRG_Est)
----------------------------------------------
If all records are read from database and written to excel means,
100% work done.
if one record read means PRG_Done value= (100 * total read records)/total recordset records.
PRG_Est value = 100 - PRG_Done.value

If any one please tell me any better idea or suggestion as i am not very expert in the progress bar.

Thanks.
0
Comment
Question by:mustish1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 18

Expert Comment

by:JR2003
ID: 18872744
If you set the Max value of the progress bar to 100.

PRG_Done value= (100 * total read records)/Total-recordset-records
(as you correctly have)


If you set the Max value of the progress bar to the Total-recordset-records then the progress done is just the number of records processed and the progress bat will look after the rest of it.


Estimate for total time:

Time-taken-so-far * Total-recordset-records / Records-read-so-far



Estimate for time to complete:

(Time-taken-so-far * Total-recordset-records / Records-read-so-far) - Time-taken-so-far
0
 

Author Comment

by:mustish1
ID: 18872752
Thanks. Can you please tell me how to i get the value of Time-taken-so-far ?
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 18872762
Does this help?

    Dim RecordCount As Integer
    Dim EstimatedTime As Date
   
    ProgressBar1.Max = RecordCount
    dtStart = Now
    For i = 1 To RecordCount

         'Read next record      

        EstimatedTime = (RecordCount - i) * (Now - dtStart) / i
        Label1.Caption = "Time left - " & Format$(EstimatedTime, "nn:ss")
        ProgressBar1.Value = i
    Next i
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:mustish1
ID: 18872934
Thanks. Can you also please tell me if there is a do while loop is running then how to i put that code into it?

do while not objrec.eof
ProgressBar1.Max = RecordCount
    dtStart = Now
    For i = 1 To RecordCount
         'Read next record      
        mDebitID =objRec.Fields(0).Value
        EstimatedTime = (RecordCount - i) * (Now - dtStart) / i
        Label1.Caption = "Time left - " & Format$(EstimatedTime, "nn:ss")
        ProgressBar1.Value = i
    Next i
objrec.movenext
loop

0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
ID: 18872956
You only need one loop, which you have provided with the Do While. Just increment the record counter (i):

    ProgressBar1.Max = RecordCount
    dtStart = Now
    Do While Not objrec.EOF
         'Read next record
        mDebitID = objrec.Fields(0).Value
        i = i + 1
        EstimatedTime = (RecordCount - i) * (Now - dtStart) / i
        Label1.Caption = "Time left - " & Format$(EstimatedTime, "nn:ss")
        ProgressBar1.Value = i
        objrec.movenext
    Loop
0
 
LVL 18

Expert Comment

by:JR2003
ID: 18872965
To get the time taken so far you just need to store the current time in a date type variable when it starts and compare it to the current-time (Now()) during the process
    Dim StartTime As Date
    Dim ElapsedTime As Date
   
    StartTime = Now()

    'Do some code here that takes some some
   
    ElapsedTime = Now() - StartTime
    Debug.Print ElapsedTime
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month11 days, 5 hours left to enroll

628 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