Home All Groups Group Topic Archive Search About

Datetime arithmetic in VB.Net?

Author
15 Mar 2006 11:52 AM
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





--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
      ------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access

Author
15 Mar 2006 1:31 PM
Armin Zingler
"Joe Befumo" <j**@befumo.com> schrieb
> 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
Author
15 Mar 2006 2:26 PM
Joe Befumo
Great, thanks so much!

Joe

Show quoteHide quote
"Armin Zingler" <az.nospam@freenet.de> wrote in message
news:OqU2nlDSGHA.4976@TK2MSFTNGP11.phx.gbl...
> "Joe Befumo" <j**@befumo.com> schrieb
>> 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



--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
      ------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access