Langkah pertama buka program Visual Basic
Loop
2. Pilih standar.exe untuk New Project kemudian Klik Open
3. Tambahkan 5 Label 1 label untuk judul dan 4 label untuk waktu masing-masing simpang, 4 frame untuk masing-masing simpang dan 12 shape dimana atur properti fillstyle mendaji solid dan fillcolor pilih warna yang sesuai serta satu buah timer dan desainlah menjadi seperti gambar dibawah ini :
4. Ubah Properti Interval pada control Timer dengan memasang nilai 1000 dan dalam keadaan false.
5. Masukkan kode program seperti dibawah ini :
Private Sub tunda()
a = Timer
Do While Timer < 1 + a
DoEvents
End Sub
Private Sub Form_Load()
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
For i = 0 To 10
Label1(0).Caption = 11 - i
Label1(1).Caption = 21 - i
Label1(2).Caption = 31 - i
Label1(3).Caption = 41 - i
If i = 0 Then
Shape10.FillColor = &HC0C0&
Shape1.FillColor = &HC0&
Shape2.FillColor = vbYellow
Shape5.FillColor = vbRed
Shape8.FillColor = vbRed
Shape11.FillColor = vbRed
Else
Shape12.FillColor = &H8000&
Shape2.FillColor = &HC0C0&
Shape3.FillColor = vbGreen
End If
tunda
Next i
For i = 10 To 20
Label1(0).Caption = 51 - i
Label1(1).Caption = 21 - i
Label1(2).Caption = 31 - i
Label1(3).Caption = 41 - i
If i = 10 Then
Shape5.FillColor = &HC0&
Shape3.FillColor = &H8000&
Shape2.FillColor = vbYellow
Shape4.FillColor = vbYellow
Else
Shape2.FillColor = &HC0C0&
Shape4.FillColor = &HC0C0&
Shape1.FillColor = vbRed
Shape5.FillColor = &HC0&
Shape6.FillColor = vbGreen
End If
tunda
Next i
For i = 20 To 30
Label1(0).Caption = 51 - i
Label1(1).Caption = 61 - i
Label1(2).Caption = 31 - i
Label1(3).Caption = 41 - i
If i = 20 Then
Shape8.FillColor = &HC0&
Shape6.FillColor = &H8000&
Shape4.FillColor = vbYellow
Shape7.FillColor = vbYellow
Else
Shape4.FillColor = &HC0C0&
Shape7.FillColor = &HC0C0&
Shape5.FillColor = vbRed
Shape8.FillColor = &HC0&
Shape9.FillColor = vbGreen
End If
tunda
Next i
For i = 30 To 40
Label1(0).Caption = 51 - i
Label1(1).Caption = 61 - i
Label1(2).Caption = 71 - i
Label1(3).Caption = 41 - i
If i = 30 Then
Shape11.FillColor = &HC0&
Shape9.FillColor = &H8000&
Shape7.FillColor = vbYellow
Shape10.FillColor = vbYellow
ElseIf i = 40 Then
Shape2.FillColor = vbYellow
Shape10.FillColor = vbYellow
Shape12.FillColor = &H8000&
Shape1.FillColor = &HC0&
Else
Shape7.FillColor = &HC0C0&
Shape10.FillColor = &HC0C0&
Shape8.FillColor = vbRed
Shape11.FillColor = &HC0&
Shape12.FillColor = vbGreen
End If
tunda
Next i
End Sub
6. Jalankan Program dan Untuk melihat contohnya bisa anda tekan tombol play dibawah
ini :
No comments:
Post a Comment