Public Class Form1
Dim TimeEnd, TimeStart, TimeStop As New DateTime
Dim isStop, isPause As Boolean
Dim form02 As New Form2
Dim foo, TimePause, ElapseTime, TotalTimePaused As New TimeSpan
Dim h, m, s As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Enabled = False
TextBox1.Text = "0" : TextBox2.Text = "0" : TextBox3.Text = "0"
Button6.Hide()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If Timer1.Interval <> 100 Then Timer1.Interval = 100
If DateTime.Now > TimeEnd Then
TextBox5.Text = "Time End"
Timer1.Stop()
Else
If isStop = False And isPause = False Then
foo = TimeEnd - DateTime.Now
TextBox5.Text = String.Format("{0:D2}:{1:D2}:{2:D2}", _
foo.Hours, foo.Minutes, foo.Seconds)
End If
TextBox6.Text = TimeStart.ToString("hh:mm" & " " & "tt")
If isStop Then
TextBox4.Text = TimeStop.ToString("hh:mm" & " " & "tt")
Else
TextBox4.Text = TimeEnd.ToString("hh:mm" & " " & "tt")
End If
TextBox1.Text = "0" : TextBox2.Text = "0" : TextBox3.Text = "0"
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'START
Button1.Hide()
Timer1.Enabled = True
If Not Integer.TryParse(TextBox1.Text, h) OrElse _
Not Integer.TryParse(TextBox2.Text, m) OrElse _
Not Integer.TryParse(TextBox3.Text, s) Then
'bad input data
Exit Sub
End If
TimeEnd = DateTime.Now.AddHours(h).AddMinutes(m).AddSeconds(s)
TimeStart = DateTime.Now
TimeOfDay = DateTime.Now
Timer1.Interval = 1
Timer1.Start()
isStop = False
End Sub
Private Sub TextBox5_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox5.TextChanged
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'STOP
isStop = True
TimeStop = DateTime.Now
' form02.PressStop = True
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
isPause = True
Timer1.Enabled = False
Button1.Hide()
Button6.Show()
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
'RESUME
If isPause = True Then
Timer1.Enabled = True
isPause = False
End If
End Sub
End Class
im working on a stop watch that can set a time then do a countdown, and do a ascending count
.im kind of a messy when it comes to this thing hope u understand the code. what im trying to do now is to make a PAUSE and RESUME button for this code. i've tried using on the Pause button timer1.enabled = false and on the RESUME button Pause button timer1.enabled = true. it does pause the time and resumes it,but for example the timer is counting down and i pause it at 5:33, and resume it after 7 seconds, the timer then resumes at 5:40, what i want to do is to make it resume from the time that i pause it, in my example i want it to resume from 5:33. hope you can help me. thanks in advance