求VB大神,帮忙做道题,大概图已经画出要求:小球沿着这3条线来回滚动,滚到那条线哪条线变成红色
做出程序必重悬赏,谢谢 展开
Dim d As Integer
Private Sub Command1_Click()
Timer1.Interval = 100
End Sub
Private Sub Command2_Click()
Timer1.Interval = 0
End Sub
Private Sub Form_Load()
For i = 0 To 2
Shape1(i).Left = i * 2000 + 200
Shape1(i).Width = 2005
Shape1(i).FillStyle = 0
Next i
Shape1(0).FillColor = vbRed
Shape2.Shape = 3
Shape2.FillStyle = 0
Shape2.FillColor = &HFF00FF
d = 100
End Sub
Private Sub Timer1_Timer()
Shape2.Left = Shape2.Left + d
If Shape2.Left < 2000 And Shape2.Left < 4000 Then
Shape1(0).FillColor = vbRed
Shape1(1).FillColor = vbBlack
Shape1(2).FillColor = vbBlack
End If
If Shape2.Left > 2000 And Shape2.Left < 4000 Then
Shape1(0).FillColor = vbBlack
Shape1(1).FillColor = vbRed
Shape1(2).FillColor = vbBlack
End If
If Shape2.Left > 4000 Then
Shape1(0).FillColor = vbBlack
Shape1(1).FillColor = vbBlack
Shape1(2).FillColor = vbRed
End If
If Shape2.Left > 6000 Or Shape2.Left < 100 Then
d = -d
End If
End Sub