Processbar in Notes: Calculate the remaing time

Just wrote an agent to update a lot of documents – included this code to calculate the remaining time:

Dim t As Variant ‘the current time
t = Getthreadinfo( 6 )

Dim cnt As Long ‘the current index

Dim max As Integer ‘the total number of documents to update
max = coll.Count

dim est as double ‘the estimated time left

est = Clng( (((Getthreadinfo( 6 )-t ) / Getthreadinfo( 7 )) / cnt ) * (max-cnt)) ‘time left in seconds
If est > 60 Then
Print Cint(( cnt / max ) * 1000 ) / 10 & “% (” & est 60 & ” min left)”
Else
Print Cint(( cnt / max ) * 1000 ) / 10 & “% (” & est & ” seconds left)”
End If

Notice the use of / and . The forward slash does a normal floating point calculation – the backslash does a integer division: 3/2 = 1,5 and 32 = 1

2 tanker om "Processbar in Notes: Calculate the remaing time"

Skriv et svar

Din e-mailadresse vil ikke blive publiceret. Krævede felter er markeret med *

*