Member Avatar for Micheal87

Hi, I have a issues, in this code I have a countdown with function declared, the issues now is that, if starting the time with only seconds timer go well but if the timer go to one minute if button is clicked timer suddently stop. Is there anything wrong with the code?

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick

        If Label5.Text = 0 AndAlso Label8.Text = 0 AndAlso Label7.Text < 59 Then
            Label7.Text = Label7.Text - 1.ToString
            If Label5.Text = 0 AndAlso Label8.Text = 0 AndAlso Label7.Text = 0 Then
                Timer1.Stop()
                MsgBox("timer out", MessageBoxButtons.OK)
            End If
            If Label7.Text = 0 AndAlso Label8.Text > 1 Then
                Label8.Text = Label8.Text - 1.ToString
                Label7.Text = 59
            ElseIf Label5.Text >= 0 AndAlso Label8.Text >= 0 AndAlso Label7.Text = 59 Then
                Label7.Text = 59
                Label8.Text = 59
                Label7.Text = Label7.Text - 1.ToString
                Label8.Text = Label8.Text - 1.ToString
                Label5.Text = Label5.Text - 1.ToString
            End If
        End If
    End Sub

You need to make sure that you do understand the difference between a string and a number.
Label5.Text = 0 should be Label5.Text = "0" . You are mixing this up throughout your code. Switch Option Strict on in the editor,

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.