主题:请教一个VB问题,有点疑惑
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 0 To a5
Shape2.FillColor = vbRed
Case a2 To a3
Shape2.FillColor = vbGreen
Shape1.FillColor = vbGreen
Case 0 To a6
Shape3.FillColor = vbRed
Case a3 To 15
Shape3.FillColor = vbGreen
Shape2.FillColor = vbGreen
Shape1.FillColor = vbGreen
End Select
Next t
End Sub
该程序的功能是
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显示正常,其余两个显示绿色没问题,但若要显示红色不能显示,任然是绿色,不发生变化。不知道是不是那段程序写错了,谢谢大家!
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 0 To a5
Shape2.FillColor = vbRed
Case a2 To a3
Shape2.FillColor = vbGreen
Shape1.FillColor = vbGreen
Case 0 To a6
Shape3.FillColor = vbRed
Case a3 To 15
Shape3.FillColor = vbGreen
Shape2.FillColor = vbGreen
Shape1.FillColor = vbGreen
End Select
Next t
End Sub
该程序的功能是
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显示正常,其余两个显示绿色没问题,但若要显示红色不能显示,任然是绿色,不发生变化。不知道是不是那段程序写错了,谢谢大家!