A need some help, I have a TextBlock that contains a string like this 00:00:00 And I want to create a timer that will count every second e.g.00:00:01 , 00:00:02 etc
So the stupid thing that I do is to take the value of the text box
string[] times = myTextbox.Text.Split(':');
int hours = Int32.Parse(times[0]);
int minutes = Int32.Parse(times[1]);
int seconds = Int32.Parse(times[2]);
Then I increase the right variable and finally I join them again and put them back in the textblock, BUT now my counter is like this: 0:0:1, 0:0:2, …
I know the problem, its very logical but my question is how can I solve it 🙂
Thank you very much.
Instead of splitting the text of the textbox i would use DateTime.Parse like this:
then add a second:
and then finally, putting it back out there:
where myPattern is replaced with any of the patterns described here: http://www.geekzilla.co.uk/View00FF7904-B510-468C-A2C8-F859AA20581F.htm