Re: [請益] 請各位幫幫我.....(剛學VB6.0= =)
'專案需一個表單,一個Timer控制項,一個Command控制項,屬性不需設定。
Dim Light As Integer, Second As Integer
Private Sub Form_Load()
Timer1.Interval = 1000 '每一秒更新一次燈號
Set Picture = Image1(Light).Picture '預設綠燈
End Sub
Private Sub Timer1_Timer()
Dim Flag As Integer
Second = Second + 1
If Light = 0 Then
If Second = 5 Then Light = 1: Flag = 1 '綠燈變黃燈
ElseIf Light = 1 Then
If Second = 2 Then Light = 2: Flag = 1 '黃燈變紅燈
Else
If Second = 7 Then Light = 0: Flag = 1 '紅燈變綠燈
End If
If Flag = 1 Then Set Picture = Image1(Light).Picture
End Sub
Private Sub Command1_Click() '手動變換燈號
Light = Light + 1
If Light = 3 Then Light = 0
Set Picture = Image1(Light).Picture
End Sub
--
VB 程式設計 倉木麻衣 PTT 星爺板 行列輸入法
======================================================
Visual_Basic MaiKuraki Stephen Array
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.222.155.162
→
61.222.155.162 05/18, , 1F
61.222.155.162 05/18, 1F
討論串 (同標題文章)
完整討論串 (本文為第 2 之 2 篇):
Visual_Basic 近期熱門文章
PTT數位生活區 即時熱門文章