I want to make 6 Timer right on top of each other. With a label to the left of it. Each label has a different time to start the countdown on. Like label 1 7 min. Label 2 6 min and so on. How do you do this in VB 2010.

Recommended Answers

All 9 Replies

like counting down minutes ? I think make a timer with interval of 60000 ms, and just put something like Label1.text -= 1

Drop a timer on your form. To get the timer to do something every one second, set the Interval property to 1000. To start the timer, set Timer1.Enabled = True. To execute code on every "tick" of the timer, put that code in the Timer1.Tick handler. To stop the timer set the Enabled property to false. You'll want to make sure that the Tick processing is not complex. You want to be done before the next Tick event. Depending on the processing you can have one timer for all fields, or one timer for each field.

Will this make 6 timers countdown at different times? And each timer has a label?

Couldn't I just make a label then next to the label make a timer? If so how do I this?

You put 1 timer and 1 label, and the code could be like this:

    Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
        Label1.Text -= 1
    End Sub

Go to the properties of the timer and set the interval how you want it, 1000 = 1 second, if you want it to decrese every 1 minute put interval as 60000 which is 60 seconds, you can set the timer enabled from the properties or from a button with:

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    Timer1.Enabled = True
End Sub

or Timer1.Start()

And the label1's text should be only numbers, so if you put 10 the label will get to 0 in 10 minutes, if you want all labels to decrese at the same time just put in the timer:

    Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
        Label1.Text -= 1
        Label2.Text -= 1
        Label3.Text -= 1
        Label4.Text -= 1
        Label5.Text -= 1
        Label6.Text -= 1
    End Sub

Ifrolox I want like it to say Human and when you click human the timer starts to go down. Instead of a label like a button I think I worded it wrong

Do you mean you want a label that says Human and start the countdowntimer by clicking on that label ?

Sorry for late reaction, my modem broke down. This is code I use for clicking on Label. Where it says do something insert what you want to happen.

Private Sub Label_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseClick, Label2.MouseClick, Label3.MouseClick, Label4.MouseClick, Label5.MouseClick, Label6.MouseClick
        Dim strName As String = ""
        Dim text As Label = sender
        strName = text.Name
        If strName = "Label1" Then
            'do something
        End If
        If strName = "Label2" Then
            'do something
        End If
        If strName = "Label3" Then
            'do something
        End If
        If strName = "Label4" Then
            'do something
        End If
        If strName = "Label5" Then
            'do something
        End If
        If strName = "Label6" Then
            'do something
        End If
    End Sub
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.