希望有人能帮我填一下代码 用vb shape 制作的跑马灯 谢谢了
展开全部
Private Sub Timer1_Timer()
Static n As Integer
Shape1(n).FillColor = vbWhite
n = (n + 1) Mod (Shape1.UBound - Shape1.LBound + 1)
Shape1(n).FillColor = vbRed
End Sub
追答
那是因为当i=0时,i-1就是-1,那么Shape1(-1)就出错了。所以要这样:
Dim i As Integer
Private Sub Command1_Click()
Shape1(i).BackColor = vbWhite
i = (i + 1) Mod 5
Shape1(i).BackColor = vbRed
End Sub
Private Sub Form_Load()
i = 4
End Sub
如果你觉得 i = (i + 1) Mod 5 难于理解,可以改为
i = i + 1
If i = 5 Then i = 0
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询