|
-
Jan 25th, 2000, 10:46 AM
#1
Thread Starter
Junior Member
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:
Code:
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).]
-
Jan 26th, 2000, 01:42 AM
#2
New Member
This routine is from my timer program which I use to keep myself from burning food while I code. Hope it helps.
Dim lngTime As Long
Dim Minutes As Integer
Dim Seconds As Integer
Private Sub Command1_Click()
'Put the number of minutes here'
lngTime = Text1 * 100
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Minutes = Int(lngTime / 100)
Seconds = lngTime Mod 100
If Seconds > 59 Then Seconds = 59
lngTime = (Minutes * 100) + Seconds
Label1 = Format(lngTime, "00:00")
lngTime = lngTime - 1
If lngTime = 0 Then
Timer1.Enabled = False
'Do Something'
End If
End Sub
-
Jan 26th, 2000, 01:45 AM
#3
New Member
P.S. Set your timer for 1000 milliseconds, or 1 second. The program will count down every second.
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
|
Click Here to Expand Forum to Full Width
|