老師出ㄌ一ㄍ作業....要我們做紅綠燈.....有規定如下:
1.滑鼠按任意鍵亮綠燈..其餘不亮
2.滑鼠按左鍵亮黃燈...其餘不亮
3.滑鼠案中或又鍵亮紅燈....其餘不亮
請問這程式碼該打啥??....拜託各位高手相助
2006-09-21 17:00:04 · 1 個解答 · 發問者 魔物獵人 1 in 教育與參考 ➔ 其他:教育
'直接將Code貼上就行'若要直接在設計階段就佈置3個Shape,那就貼上Form_MouseDown那段Code就行Dim Shape1(2) As ShapePrivate Sub Form_Load() '產生3個Shape Dim I As Integer, L As Integer L = 300 For I = 2 To 0 Step -1 Set Shape1(I) = Controls.Add("VB.Shape", "Sh" & I) With Shape1(I) .BackStyle = 1 .Shape = 3 .Move L, 300, 435, 435 .BackColor = vbGrayText .Visible = True End With L = L + 600 NextEnd SubPrivate Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) Dim I As Byte Static B As Boolean For I = 0 To 2 Shape1(I).BackColor = vbGrayText Next If B Then If Button = 1 Then Shape1(1).BackColor = vbYellow Else Shape1(2).BackColor = vbRed B = False End If Else Shape1(0).BackColor = vbGreen B = True End IfEnd Sub
2006-09-22 12:00:08 · answer #1 · answered by W.J.S. 7 · 0⤊ 0⤋