Stop Watch Question
Posted on 2006-10-30
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,
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