Goodday, I use the below code to start a timer .
Label2.Text = Difference1.TotalMinutes.ToString(“N0”)
But the minutes are always 30 seconds out. The label shows the time as 1 minute when only 30 seconds have elapsed and thereafter I’m always 30 seconds out.
How can I calibrate this?
Thanks
Rob
Goodday, I use the below code to start a timer . Label2.Text = Difference1.TotalMinutes.ToString(N0)
Share
If you look at the definition for the TimeSpan.TotalMinutes property it states that it:
Therefore when you use the ToString(“N0“) format you are telling it that you want no decimal places and since it is a numeric format it will round your value up. You should look at using the
TimeSpan Custom Formatsin particular in this case the %m Custom Format string. It should look something like this:Code I used to test. Timer interval is set to 1000 and is enabled.