I want to add a label that prints the elapsed time like a normal clock (when seconds reachs “59” then add “1” min to the counter) but my time span add minutes when the seconds reaches the number “30”… what I’m doing wrong?
Dim ElapsedTime As TimeSpan
While log_button.Text = "Stop logger"
ElapsedTime = Now().Subtract(StartTime)
Label5.Text = String.Format("Minutos transcurridos: {0:00}:{1:00}", CInt(ElapsedTime.TotalMinutes) Mod 60, CInt(ElapsedTime.TotalSeconds) Mod 60)
Application.DoEvents()
End While
I get a wrong incrementation like this:


00:01
…
00:28
00:29
00:30
01:31
01:32
etc…
That’s because you are rounding the floating point number that represents total minutes. When the numbers reaches
0.5it will be rounded to 1.Use the
Floormethod to truncate the number:You can also use the
Minutesproperty, that does all that: