First of all, the form has a textbox where the user has to input the time to countdown like this: 1:10 < this means 1 minute and 10 seconds
the form has also 3 labels, 1 named countminutes, other countseconds and another label1 with the text ":"
here's the code, the problem is that it counts the time, but blocks the app till it ends, wich result on not showing the counttime like it should:
CODE
Imports System.Threading.Thread
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim time() As String
time = Split(timetowait.Text, ":", , CompareMethod.Text)
countminutes.Text = time(0)
countseconds.Text = time(1)
Dim minutes As Integer = time(0)
Dim seconds As Integer = time(1)
start:
If seconds = 0 And minutes = 0 Then
GoTo stops
End If
If seconds = 0 Then
minutes -= 1
seconds = 60
End If
seconds -= 1
countminutes.Text = minutes
countseconds.Text = seconds
Sleep(1000)
GoTo start
stops:
MsgBox("countdown off")
End Sub
End Class
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim time() As String
time = Split(timetowait.Text, ":", , CompareMethod.Text)
countminutes.Text = time(0)
countseconds.Text = time(1)
Dim minutes As Integer = time(0)
Dim seconds As Integer = time(1)
start:
If seconds = 0 And minutes = 0 Then
GoTo stops
End If
If seconds = 0 Then
minutes -= 1
seconds = 60
End If
seconds -= 1
countminutes.Text = minutes
countseconds.Text = seconds
Sleep(1000)
GoTo start
stops:
MsgBox("countdown off")
End Sub
End Class
If someone could help me would be cool.
If i pull this out before someone helps me i'll post the new code in here.
Thanks in advance.
~
Joćo Lopes
*edit*
Posted the attached file.
*edit*
Problem solved, i'll leave the 1st source there and attach another, the 1st source has nothing important, but uses the function sleep, and i don't know if it will not be needed around.
and the code is this one (note, now a timer is needed, named timer1)
CODE
Imports System.Threading.Thread
Public Class Form1
Private Sub Button1_Click(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
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim minutes As Integer = countminutes.Text
Dim seconds As Integer = countseconds.Text
If 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
countminutes.Text = minutes
countseconds.Text = seconds
End If
End Sub
End Class
Public Class Form1
Private Sub Button1_Click(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
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim minutes As Integer = countminutes.Text
Dim seconds As Integer = countseconds.Text
If 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
countminutes.Text = minutes
countseconds.Text = seconds
End If
End Sub
End Class

