某程序的功能是a1<=q<a2,Shape1.FillColor = vbGreen;q<a4,Shape1.FillColor = vbRed
a2<=q<a3,Shape2.FillColor = vbGreen,Shape2.FillColor = vbGreen ;q<a5,Shape2.FillColor = vbRed
a3<=q<15,Shape3.FillColor = vbGreen,Shape2.FillColor = vbGreen,Shape1.FillColor = vbGreen;q<a6,Shape3.FillColor = vbRed
我寫的程序存在的問題:shape1顯示正常,其余兩個顯示綠色沒問題,但若要顯示紅色不能顯示,任然是綠色,不發生變化。
Private Sub Command2_Click()
Const pi = 3.14159
Dim t As Single, y As Single, p As Single
Dim a1 As Single, a2 As Single, a3 As Single, a4 As Single, a5 As Single, a6 As Single, q As Single
a1 = Val(Text1.Text)
a2 = Val(Text2.Text)
a3 = Val(Text3.Text)
a4 = Val(Text4.Text)
a5 = Val(Text5.Text)
a6 = Val(Text6.Text)
For t = 0 To 24 Step 0.0003
y = -2 * Sin(t * pi / 1.5) + 3
p = y / 5
Text8.Height = Text7.Height * (1 - p)
q = p * 15
Text9.Text = q
Shape1.Refresh
DoEvents
Select Case q
Case 0 To a4
Shape1.FillColor = vbRed
Case a1 To a2
Shape1.FillColor = vbGreen
Case a4 To a5
Shape2.FillColor = vbRed
Case a2 To a3
Shape2.FillColor = vbGreen
Shape1.FillColor = vbGreen
Case a5 To a6
Shape3.FillColor = vbRed
Case a3 To 15
Shape3.FillColor = vbGreen
Shape2.FillColor = vbGreen
Shape1.FillColor = vbGreen
End Select
Next t
End Sub
[ 此帖被18063219在2010-04-29 20:41重新編輯 ]