Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert milliseconds to minutes etc... 2

Status
Not open for further replies.

mancroft

Programmer
Oct 26, 2002
267
GB
Convert milliseconds to minutes etc...

Hello

I have got code to display milliseconds.

What is the best way to display the milliseconds in minutes/seconds?

Thank you.


Code:
Dim swatch As New Stopwatch()

swatch.Start()  

do

statuslabel.Text = swatch.ElapsedMilliseconds.ToString

etcetera
 
Usually when you solve a problem you should post your solution so that other people with the same problem later can see how you solved it.

In this case, I would assume you did something like this:

MilliSeconds / 1000 = Seconds
MilliSeconds / 1000 / 60 = Minutes
MilliSeconds / 1000 / 60 / 60 = Hours

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
A sound idea, Rick!

Code:
Public timerstarted As Boolean = False
Public swatch As New Stopwatch()

If timerstarted = True Then

Dim ts As TimeSpan = TimeSpan.FromMilliseconds(swatch.ElapsedMilliseconds)
statuslabel.Text = ts.Minutes.ToString() & ":" & ts.Seconds.ToString()

End If

swatch.Start()
timerstarted = True
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top