I'm using a timer which counts up on a button click when i press it, and when it reaches the time i desire, usually around the 45 minute mark i click my other button which stops the timer and the time remains static, so if i click my button to stop and my label says "45:34" then it will just stay like that as a static label. This is fine, i have done all this with no problem. The problem i have though is being able to resume this timer but start it from "45:00" instead of "00:00"
Dim starttime As DateTime 'Timer settings' Private Sub Timer3_Tick(sender As Object, e As EventArgs) Handles Timer3.Tick Dim timedifference As TimeSpan = DateTime.Now.Subtract(starttime) Dim newdate As DateTime = timedifference.ToString Label7.Text = newdate.ToString("mm:ss") End Sub 'Stops/pauses the timer' Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click Timer2.Stop() 'This is my other timer, not related to this' Timer3.Stop() 'This is the timer which controls the label ie the ticking minutes' Label8.Text = "Match Paused..." Button7.Enabled = True End Sub 'When i click this button the timer starts counting from 00:00' Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click Timer3.Start() starttime = DateTime.Now
When i click a seperate button, let's say button9 for example, the timer should reset to "45:00" and start counting up in label7 just like it did before.
I believe it involves part of this code
starttime = DateTime.Now
But instead of 'Now' it would be something else?
Edited 2 Years Ago by pbarks1