paulbacca 0 Report post Posted January 4, 2008 (edited) Hi all,Can you help me with the script below. I found this code on a old posting. I would like to able too input a value for hours and have that countdown also.ThanksPaul Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Dim hours As Integer = countminutes.Text Dim minutes As Integer = countminutes.Text Dim seconds As Integer = countseconds.Text If hours = 0 And minutes = 0 And seconds = 0 Then 'MsgBox("Time Ended") Timer1.Stop() End If If seconds = 0 Then minutes -= 1 seconds += 60 End If seconds -= 1 If minutes <> -1 Then counthours.Text = minutes countminutes.Text = minutes countseconds.Text = seconds End If End Sub Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If InStr(timetowait.Text, ":") Then Dim time() As String time = Split(timetowait.Text, ":", , CompareMethod.Text) countminutes.Text = time(0) countseconds.Text = time(1) Timer1.Interval = 1000 Timer1.Start() Else : MsgBox("You have to insert like this 1:10") End If End Sub Edited January 4, 2008 by paulbacca (see edit history) Share this post Link to post Share on other sites
iGuest 3 Report post Posted November 28, 2009 Try thisCountdown TimerShould be something similar to this: Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Dim hours As Integer = counthours.Text Dim minutes As Integer = countminutes.Text Dim seconds As Integer = countseconds.Text If hours = 0 And minutes = 0 And seconds = 0 Then 'MsgBox("Time Ended") Timer1.Stop() End If If seconds = 0 Then minutes -= 1 seconds += 60 End If If minutes = 0 Then hours -= 1 minutes += 60 End If seconds -= 1 If minutes <> -1 Then counthours.Text = hours countminutes.Text = minutes countseconds.Text = seconds End If End Sub Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If InStr(timetowait.Text, ":") Then Dim time() As String time = Split(timetowait.Text, ":", , CompareMethod.Text) counthours.Text = time(0) countminutes.Text = time(1) countseconds.Text = time(2) Timer1.Interval = 1000 Timer1.Start() Else : MsgBox("You have to insert like this 1:20:30") End If End Sub Share this post Link to post Share on other sites
iGuest 3 Report post Posted August 3, 2010 Private Sub btnTimer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTimer.Click If InStr(timetowait.Text, ":") Then Dim time() As String time = Split(timetowait.Text, ":", , CompareMethod.Text) counthours.Text = time(0) countminutes.Text = time(0) countseconds.Text = time(1) Timer1.Interval = 1000 Timer1.Start() Else : MsgBox("You have to insert like this 00:00:00") End If End SubPrivate Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick Dim hours As Integer = counthours.Text() Dim minutes As Integer = countminutes.Text Dim seconds As Integer = countseconds.Text If hours = 0 And minutes = 0 And seconds = 0 Then Timer1.Stop() MsgBox("Time Ended") MsgBox("Answer!") End If If minutes = 0 Then hours -= 1 minutes += 60 End If If seconds = 0 Then minutes -= 1 seconds += 60 End If seconds -= 1 If minutes <> -1 Then counthours.Text = hours countminutes.Text = minutes countseconds.Text = seconds End If End Sub Share this post Link to post Share on other sites