Solved

Estimated Time and Work Done

Posted on 2007-04-08
6
157 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
  • 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now