All the control has default name, timer control cant be displayed since it wasnt suppose to be shown on the form itself, but its there with the name timer1.Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'what we do here is to set up the ticks to be counted as 1 tick per seconds (the unit used here is miliseconds'
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
'do a check if the label is already zero then the number wont decrease to avoid negative value'
If Label1.Text = 0 Then
Timer1.Enabled = False
Else
'This piece actually makes the number goes down every second ( minus 1 from the label each seconds'
Label1.Text = Label1.Text - 1
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Timer1.Enabled = False
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Timer1.Enabled = False
Label1.Text = "30"
End Sub
End Class
Labels: vb.net
