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 3\2 = 1
Monday, February 2, 2009
Subscribe to:
Post Comments (Atom)


2 comments:
Interesting. Tx for the code.
2 questions: where is 'max' defined ? Shouldn't it be 'total' ?
Why the disclaimer ?
Fixed the typos - thanx :-)
Disclaimer came from the email I sent to the blog - now it's deleted ....
Post a Comment