Reputation: 215
I have a timer and I want to display the minutes and seconds. my timer goes up, and when there are 60 seconds, there should be a minute, and seconds must be nulled. Now it simply counts the in seconds. I hope for your help.
Private timer As DispatcherTimer
Private CountUp As Integer
Public Sub DispatcherTimerSetup()
timer = New DispatcherTimer()
timer.Interval = New TimeSpan(0, 0, 1)
AddHandler timer.Tick, AddressOf timer_Tick
timer.Start()
End Sub
Private Sub timer_Tick(sender As Object, e As Object)
CountUp += 1
txblCountdown.Text = CountUp.ToString("00\:00")
'timeformat
End Sub
best regards, Polina
Upvotes: 0
Views: 385
Reputation: 4322
You can use a TimeSpan to do this.
Private Sub timer_Tick(sender As Object, e As Object)
CountUp += 1
Dim counter As TimeSpan
counter = TimeSpan.FromSeconds(CountUp)
txblCountdown.Text = counter.ToString("mm\:ss")
End Sub
Upvotes: 1