Traffic Signal with Timer Using Visual Studio
Code :
Public Class Form1
Dim counte As Integer = 0
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
counte = counte + 1
If counte > 0 And counte <= 30 Then
PictureBox1.Show()
PictureBox2.Hide()
PictureBox3.Hide()
ElseIf counte > 30 And counte < 35 Then
PictureBox1.Hide()
PictureBox2.Show()
PictureBox3.Hide()
ElseIf counte > 35 And counte < 65 Then
PictureBox1.Hide()
PictureBox2.Hide()
PictureBox3.Show()
ElseIf counte > 65 Then
counte = 0
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Timer1.Start()
End Sub
Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles PictureBox1.Click
End Sub
Private Sub PictureBox2_Click(sender As Object, e As EventArgs) Handles PictureBox2.Click
End Sub
End Class
Output:
Comments