Salutare, revin si eu cu o problema in vb.net.
Vreau sa fac un stopwatch care sa inregistreze orele, minutele si secundele. Problema este ca in momentul in care se fac 00:00:59 ar trebui sa arate dupa o secunda 00:01:00, dar la mine continua la infinit secundele si nu se resteaza.
Code:
Public Class Form1
Private stopwatch_donone As New Diagnostics.Stopwatch
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub don1_timer_Tick(sender As Object, e As EventArgs) Handles don1_timer.Tick
Dim donone_elapsed As TimeSpan = stopwatch_donone.Elapsed
donone_timerwatch.Text = String.Format("{0:00}:{1:00}:{2:00}", Math.Floor(donone_elapsed.TotalHours), Math.Floor(donone_elapsed.TotalMinutes), Math.Floor(donone_elapsed.TotalSeconds))
End Sub
Private Sub donone_startbutton_Click(sender As Object, e As EventArgs) Handles donone_startbutton.Click
If donone_startbutton.Text = "Start" Then
don1_timer.Start()
stopwatch_donone.Start()
donone_startbutton.Text = "Stop"
ElseIf donone_startbutton.Text = "Stop" Then
don1_timer.Stop()
stopwatch_donone.Stop()
donone_startbutton.Text = "Start"
End If
End Sub
Private Sub donone_resetbutton_Click(sender As Object, e As EventArgs) Handles donone_resetbutton.Click
stopwatch_donone.Reset()
donone_timerwatch.Text = "00:00:00"
End Sub