Berikut adalah tampilan form
untuk LAMPU.Terdiri dari 3 buah TIMER yang dimaksud untuk menjalankan waktu. Dan 3 buah Shape Circle.
Berikut adalah Listing yang dapat
dituliskan agar dapat menjalankan program lampu :
Code 1:
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Shape2.BackColor = vbRed
Shape3.BackColor = vbWhite
Shape4.BackColor = vbWhite
Label1.Caption = Label1.Caption -
1
If Label1.Caption = 0 Then
Timer1.Enabled = False
Timer2.Enabled = True
Label1.Caption = 3
Shape2.BackColor = vbWhite
Shape3.BackColor = vbYellow
Shape4.BackColor = vbWhite
End If
End Sub
Private Sub Timer2_Timer()
Label1.Caption = Label1.Caption -
1
If Label1.Caption = 0 Then
Timer2.Enabled = False
Timer3.Enabled = True
Label1.Caption = 10
Shape2.BackColor = vbWhite
Shape3.BackColor = vbWhite
Shape4.BackColor = vbGreen
End If
End Sub
LOGIKA LAMPU :
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Shape2.BackColor = vbRed
Shape3.BackColor = vbWhite
Shape4.BackColor = vbWhite
Label1.Caption = Label1.Caption -
1
If Label1.Caption = 0 Then
Timer1.Enabled = False
Timer2.Enabled = True
Label1.Caption = 3
Shape2.BackColor = vbWhite
Shape3.BackColor = vbYellow
Shape4.BackColor = vbWhite
End If
End Sub
Private Sub Timer2_Timer()
Label1.Caption = Label1.Caption -
1
If Label1.Caption = 0 Then
Timer2.Enabled = False
Timer3.Enabled = True
Label1.Caption = 10
Shape2.BackColor = vbWhite
Shape3.BackColor = vbWhite
Shape4.BackColor = vbGreen
End If
End Sub