Re: [請益] 請各位幫幫我.....(剛學VB6.0= =)

看板Visual_Basic作者 (小獅)時間19年前 (2005/05/18 10:20), 編輯推噓0(001)
留言1則, 1人參與, 最新討論串2/2 (看更多)
'專案需一個表單,一個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
文章代碼(AID): #12YgQ2hI (Visual_Basic)
文章代碼(AID): #12YgQ2hI (Visual_Basic)