aussiejoe
Jan 25th, 2000, 09:46 AM
i am attempting to make a label which will show the number of seconds remaining before my function finishes. I have it updating a progress bar to 100%, this works fine. i cannot however, get it to work out the correct remaining time. Here is the basic source:
Public Function DoSuch(SomeVar)
sttime = Timer
For i = 1 To SomeVar
ProgBar.Value = 33.3 / SomeVar * i If i Mod 3 = 0 Then
ltime = Timer - sttime
ProgLabel.Caption = ltime / ProgBar.Value * 100 'time so far / % so far * 100
ProgLabel.Refresh
'do some stuff here
Next i
For i = 1 To SomeVar
ProgBar.Value = (33.3 / SomeVar * i) + 33.3
ltime = Timer - sttime
ProgLabel.Caption = ltime / ProgBar.Value * 100
ProgLabel.Refresh
'doing something else here
Next i
For i = 1 To SomeVar
ProgBar.Value = (33.3 / SomeVar * i) + 66.6 ' progressbar
ltime = Timer - sttime
ProgLabel.Caption = ltime / ProgBar.Value * 100
ProgLabel.Refresh
'do final thing here
Next i
End Function
The 3 loops cannot be separated, as they all rely on the previous loops output.
The problem that occurs is that the label which *should* show the seconds remaining, actually counts upwards slowly, rather than down quite quickly. Any ideas or suggestions are welcomed, thanks.
[This message has been edited by aussiejoe (edited 01-25-2000).]
Public Function DoSuch(SomeVar)
sttime = Timer
For i = 1 To SomeVar
ProgBar.Value = 33.3 / SomeVar * i If i Mod 3 = 0 Then
ltime = Timer - sttime
ProgLabel.Caption = ltime / ProgBar.Value * 100 'time so far / % so far * 100
ProgLabel.Refresh
'do some stuff here
Next i
For i = 1 To SomeVar
ProgBar.Value = (33.3 / SomeVar * i) + 33.3
ltime = Timer - sttime
ProgLabel.Caption = ltime / ProgBar.Value * 100
ProgLabel.Refresh
'doing something else here
Next i
For i = 1 To SomeVar
ProgBar.Value = (33.3 / SomeVar * i) + 66.6 ' progressbar
ltime = Timer - sttime
ProgLabel.Caption = ltime / ProgBar.Value * 100
ProgLabel.Refresh
'do final thing here
Next i
End Function
The 3 loops cannot be separated, as they all rely on the previous loops output.
The problem that occurs is that the label which *should* show the seconds remaining, actually counts upwards slowly, rather than down quite quickly. Any ideas or suggestions are welcomed, thanks.
[This message has been edited by aussiejoe (edited 01-25-2000).]