Ah, sorry about that. I have used code like this before and I left a bit out. You do use TotalMinutes, not Minutes, but to account for the issue you mention you have to trucate the decimal part first. Change my code to this:The Math.Floor method will remove the decimal part of the value, thus ensuring it will never be rounded up.vb.net Code:
Dim elapsed As TimeSpan = myStopwatch.Elapsed MessageBox.Show(String.Format("{0:00}:{1:00}.{2:000}", _ Math.Floor(elapsed.TotalMinutes), _ elapsed.Seconds, _ elapsed.Milliseconds))




Reply With Quote