Link to home
Start Free TrialLog in
Avatar of gr8life
gr8life

asked on

Stop Watch Question

I am using the below code as a stopwatch.  Is it possible to adapt the code to be more accurate? Currently it displays results as: hours, minutes, and seconds.  I need to also display smaller increments such as tenths of a second. So the desired result includes the original result as well as the tenths of a second as well.

Thank you for your time,
Gr8life


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Button1.Enabled = False

        Dim startDT As DateTime = DateTime.Now

        Dim stopDT As DateTime = DateTime.Now

        Dim elapsedTS As TimeSpan = stopDT.Subtract(startDT)
        Dim msg As String = elapsedTS.Hours & "h" & elapsedTS.Minutes & "m" & elapsedTS.Seconds & "s"
        MessageBox.Show("Process duration: " & msg)

        Button1.Enabled = True
    End Sub
SOLUTION
Avatar of gangwisch
gangwisch

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gr8life
gr8life

ASKER

Gangwisch, I was looking for more along the line of what TVoteyDisciple posted.  Thank you for your time.

TVoteyDisciple your answer is close enough.
 
Fernando, thank you for your response, but unfortunately I still have 2003.  Hopefully someone will read this post and be able to use your valuable code.

thanks everyone,
Gr8life