Berikut ini adalah salah satu program untuk lampu lalu lintas menggunakan visual basic.
Option Explicit
Dim M As Integer
Private Sub Form_Load()
Timer1.Interval = 1000
Timer1.Enabled = True
M = 10
End Sub
Private Sub Timer1_Timer()
M = M - 1
If M > 4 And M < 10 Then
Shape1.FillColor = vbRed
Shape2.FillColor = vbBlack
Shape3.FillColor = vbBlack
Label1.Caption = M - 4
ElseIf M > 1 And M < 5 Then
Shape3.FillColor = vbGreen
Shape2.FillColor = vbBlack
Shape1.FillColor = vbBlack
Label1.Caption = M - 1
ElseIf M = 1 Then
Shape2.FillColor = vbYellow
Shape3.FillColor = vbBlack
Shape1.FillColor = vbBlack
Label1.Caption = ""
M = 10
End If
End sub
Tidak ada komentar:
Posting Komentar