Here is a generic method I use to return the progress ‘X of Y (XX time so far, YY remaining)’. It uses a couple of other methods to display a long integer, the percentage, date difference and seconds as time you can roll your own. I get the start time once then pass it into this method along with the item and total items.
[code]Protected Function getTimeRemainingWAD(upToValue As Integer, totalValues As Integer, timeStarted As Date, showPercentage As Boolean = True , timeRemaining As Boolean = True, timeSoFar As Boolean = True) as String
Dim tempDate As New Date
Dim myString As String
Dim bracketText As String
Dim secondsDifference As Integer
Dim secondsRemaining As Integer
if upToValue > totalValues then upToValue = totalValues 'presumeably a mistake!
if upToValue < 0 or totalValues < 0 or timeStarted = nil or tempDate.TotalSeconds < timeStarted.TotalSeconds then Return “”
secondsDifference = tempDate.TotalSeconds - timeStarted.TotalSeconds 'current time less time started
secondsRemaining = secondsDifference * ((totalValues - upToValue) / upToValue)
myString = commonStrings.getLargeDecimalWAD(upToValue) + " of " + commonStrings.getLargeDecimalWAD(totalValues)
if not showPercentage and not timeRemaining and not timeSoFar then 'don’t bother with the brackets!
Return myString
end if
if showPercentage then
bracketText = bracketText + commonStrings.getNumberAsPercentageWAD(upToValue / totalValues) + ", "
end if
if timeSoFar then
bracketText = bracketText + getDateDifferenceWAD(timeStarted, tempDate, “”, True, True, True) + " so far, "
end if
if timeRemaining then
bracketText = bracketText + getShowTimeWAD(secondsRemaining) + " remaining, "
end if
if right(bracketText, 2) = ", " then bracketText = left(bracketText, len(bracketText) - 2)
myString = myString + " (" + bracketText + “)”
Return myString
End Function
[/code]