-
subtracting time
I'm having trouble calculating the correct time laps.
start_time = DateTime.Now
(program code)
Dim processing_time As TimeSpan = DateTime.Now - start_time
msgbox(processing_time.Minutes)
start - 3/13/2013 7:49:30 PM
end - 3/13/2013 10:57:10 PM
My result was 7 mins. It seems like my code is not subtracting the hours. How do I correct this?
-
Re: subtracting time
Try
Code:
msgbox(processing_time.TotalMinutes)
..and about the subtraction i would use Subtract() method
Code:
Dim MinCount As Double = DateTime.Now.Subtract(start_time).TotalMinutes
-
Re: subtracting time
How about using a Stopwatch
Code:
Dim stpw As New Stopwatch
stpw.Reset()
stpw.Restart()
'code to be timed
stpw.Stop()
Debug.WriteLine(stpw.Elapsed.ToString)