题库 题库

【简答题】

参考答案

Dim a%, b As Boolean
Private Sub C1_Click()
    Timer2.Enabled = True
    b = True
End Sub
Private Sub Timer1_Timer()
    a = a + 1
    If a > 6 Then
        a = 1
    End If
    Select Case a
        Case 1
            P1.Picture = LoadPicture("黄灯.ico")
        Case 2, 3
            P1.Picture = LoadPicture("红灯.ico")
        Case 4, 5, 6
            P1.Picture = LoadPicture("绿灯.ico")
            If b Then Timer2.Enabled = True
    End Select
End Sub
Private Sub Timer2_Timer()
    If (a < 4) And (P2.Left > P1.Left And P2.Left < P1.Left + P1.Width) Or P2.Left <= 100 Then
        Timer2.Enabled = False
    Else
        P2.Move Form1.P2.Left - 10, P2.Top, P2.Width, P2.Height
    End If
End Sub

相关试题