Hi @RogerSchlueter-7899 ,
Timer ticks aren't precise. Subtracting 1 second per tick accumulates drift and causes jumps when ticks are missed. Instead of decrementing a counter, please try calculating remaining time from a fixed endpoint.
Here is an example based by Copilot:
Private EndTime As DateTime
Private Sub StartClock(sender As Object, e As RoutedEventArgs) Handles btnStart.Click
' Set target end time once
EndTime = DateTime.Now.AddSeconds(StartPeriod)
tmr = New Timer(1000) With {.AutoReset = True, .Enabled = True}
AddHandler tmr.Elapsed, AddressOf UpdateClock
End Sub
Private Sub PopulateTimer()
' Calculate from current time each tick
Dim remaining As TimeSpan = EndTime - DateTime.Now
If remaining.TotalSeconds > 0 Then
txtRemaining.Text = $"{CInt(remaining.TotalHours):00}:{remaining.Minutes:00}:{remaining.Seconds:00}"
Else
txtRemaining.Text = "00:00:00"
tmr.Stop()
End If
End Sub
In this approach, each tick recalculates based on the actual clock time, so any missed or delayed ticks automatically correct on the next update and no error buildup over time.