VB问题(一个计算汽车收费问题)

来源:百度知道 编辑:UC知道 时间:2024/05/16 14:50:19
Option Explicit
Private Sub Command1_Click()
Dim x As Single,
x = Val(Text1.Text)
Text2.Text = ""
Select Case True
Case Option1.Value
If x <= 100 Then
Text2.Text = 10
ElseIf 200 >= x >= 100 Then Text2.Text = 10 + (x - 100) * 1.2
ElseIf 350 >= x >= 200 Then Text2.Text = 20 + (x - 200) * 1.2
ElseIf x >= 350 Then Text2.Text = 50 + (x - 350) * 1.2
End If
Case Option2.Value
If x <= 100 Then
Text2.Text = 10
ElseIf 200 >= x >= 100 Then Text2.Text = 20 + (x - 100) * 1.5
ElseIf 350 >= x >= 200 Then Text2.Text = 35 + (x - 200) * 1.5
ElseIf x >= 350 Then Text2.Text = 50 + (x - 350) * 1.5
End If
Case Option3.Value
If x <= 100 Then
Text2.Text = 10
ElseIf 200 >= x >= 100 Then Text2.Text = 20 + (x - 100) * 1.8
ElseIf 350 >= x >= 200 Then Text2.Text = 35 + (x - 200) * 1.8
ElseIf x >= 350 Then Text2.Text = 50 + (x -

Option Explicit
Private Sub Command1_Click()
Dim x As Single
x = Val(Text1.Text)
Text2.Text = ""
Select Case True
Case Option1.Value
If x <= 100 Then
Text2.Text = 10
ElseIf 200 >= x Then Text2.Text = 10 + (x - 100) * 1.2
ElseIf 350 >= x Then Text2.Text = 20 + (x - 200) * 1.2
ElseIf x >= 350 Then Text2.Text = 50 + (x - 350) * 1.2
End If
Case Option2.Value
If x <= 100 Then
Text2.Text = 10
ElseIf 200 >= x Then Text2.Text = 20 + (x - 100) * 1.5
ElseIf 350 >= x Then Text2.Text = 35 + (x - 200) * 1.5
ElseIf x >= 350 Then Text2.Text = 50 + (x - 350) * 1.5
End If
Case Option3.Value
If x <= 100 Then
Text2.Text = 10
ElseIf 200 >= x Then Text2.Text = 20 + (x - 100) * 1.8
ElseIf 350 >= x Then Text2.Text = 35 + (x - 200) * 1.8
ElseIf x >= 350 Then Text2.Text = 50 + (x - 350) * 1.8
End If
End Select
End Sub
I