Datetime arithmetic in VB.Net?

  • Thread starter Thread starter Joe Befumo
  • Start date Start date
J

Joe Befumo

I have a program that processes a large number of records & would like to
display the remaining time, in days:hours:minutes.

I'm looking to do something like:

Dim tsTimeRemaining as System.Timespan
Dim tsElapsedTime as System.Timespan
dtTimeRemaining = intRemainingRecords * (tsElapsedTime /
intRecordsAlreadyProcessed)

Could someone help me out with the appropriate arithmetic
operators/casts/etc.



Thanks.



Joe
 
Joe Befumo said:
I have a program that processes a large number of records & would
like to display the remaining time, in days:hours:minutes.

I'm looking to do something like:

Dim tsTimeRemaining as System.Timespan
Dim tsElapsedTime as System.Timespan
dtTimeRemaining = intRemainingRecords * (tsElapsedTime /
intRecordsAlreadyProcessed)

Could someone help me out with the appropriate arithmetic
operators/casts/etc.

Function GetTotalTime( _
ByVal Counter As Integer, _
ByVal Total As Integer, _
ByVal Elapsed As TimeSpan, _
ByRef Remaining As TimeSpan) _
As TimeSpan

GetTotalTime = TimeSpan.FromSeconds(Elapsed.TotalSeconds / Counter *
Total)
Remaining = GetTotalTime.Subtract(Elapsed)

End Function

Returns the total time as the function value and the remaining time as a
parameter.


Armin
 
Great, thanks so much!

Joe

Armin Zingler said:
Function GetTotalTime( _
ByVal Counter As Integer, _
ByVal Total As Integer, _
ByVal Elapsed As TimeSpan, _
ByRef Remaining As TimeSpan) _
As TimeSpan

GetTotalTime = TimeSpan.FromSeconds(Elapsed.TotalSeconds / Counter *
Total)
Remaining = GetTotalTime.Subtract(Elapsed)

End Function

Returns the total time as the function value and the remaining time as a
parameter.


Armin
 
Back
Top