h1

Traffic Light (1) Buat Vita Programmer Gadungan

Desember 13, 2009

Best Answer – Chosen by Asker
The only thing i’m not sure of is how to make TAB activate the lights. But, this is what you have to do:

1. Lay out the 3 picture boxes.
2. Use “BackColor” to fill them in ( start with just green)
3. Make a timer
4. Under the timer make a counter and then an if statement to reset the counter after 4 loops. Then make 3 if statements, one for each counter (1,2,3). Under each “if”, put the next lights fillcolor and hide the other two. Repeat this pattern

Sample

—Ne Codenya–

Dim Counter As Single
Private Sub Timer1_Timer()
Counter = Counter + 1
If Counter = 4 Then
Counter = 1
End If
If Counter = 1 Then
Picture1.BackColor = &HC000&
Picture2.BackColor = vbWhite
Picture3.BackColor = vbWhite
End If
If Counter = 2 Then
Picture2.BackColor = &HFFFF&
Picture1.BackColor = vbWhite
Picture3.BackColor = vbWhite
End If
If Counter = 3 Then
Picture3.BackColor = vbRed
Picture1.BackColor = vbWhite
Picture2.BackColor = vbWhite
End If

End Sub

Tinggalkan Balasan

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Ubah )

Twitter picture

You are commenting using your Twitter account. Log Out / Ubah )

Facebook photo

You are commenting using your Facebook account. Log Out / Ubah )

Connecting to %s

Ikuti

Get every new post delivered to your Inbox.