下面这段VB红绿灯的代码哪错了

2025-04-26 23:32:53
推荐回答(5个)
回答1:

是用Fillcolor而不是用Backcolor

Option Explicit
Private Sub Form_Click()
Static i As Integer
Shape1.FillStyle = 0
If i = 0 Then
Shape1.FillColor = vbRed
ElseIf i = 1 Then
Shape1.FillColor = vbGreen
ElseIf i = 2 Then
Shape1.FillColor = vbYellow
End If
i = i + 1
If i = 3 Then
i = 0
End If
End Sub

回答2:

代码没错,
加入下面一句:
Shape1.FillStyle = 0

回答3:

把 Static i As Integer 放sub过程 外试试

回答4:

.

回答5:

没问题啊