请帮忙做个VB题!有参考代码

来源:百度知道 编辑:UC知道 时间:2024/07/06 12:53:35
某商场为了加速促成商品流通。采用购物打折的优惠办法,每位顾客一次购物200元以上者,按九五折优惠;在400元以上者,按九折优惠;600元以上者,按八折优惠;1000元以上者按七折优惠。在窗体上添加两个文本框和一个按钮,要求在text1中输入购物商品总金额,单击按钮在text2中输出优惠价。

-----------------------------------
Private Sub Command1_Click()
Dim x As Single, y As Single
x = Val(Text1.Text)
If x < 200 Then
y = x
Else
If x < 400 Then
y = 0.95 * x
Else
If x < 800 Then
y = 0.9 * x
Else
y = 0.8 * x
End If
End If
End If
Text2.Text = y
End Sub
麻烦大家了

Private Sub Command1_Click()
Dim x As Single, y As Single
x = Val(Text1.Text)
If x < 200 Then
y = x
Else
If x < 400 Then
y = 0.95 * x
Else
If x < 600 Then
y = 0.9 * x
else
If x < 1000 Then
y = 0.8 * x
Else
y = 0.7 * x
End If
End If
End If
end if

Text2.Text = y
End Sub

Private Sub Command1_Click()

If Val(Text1.Text) <= 200 Then

Text2.Text = "200"
ElseIf Val(Text1.Text) > 200 And Val(Text1.Text) <= 400 Then

Text2.Text = Val(Text1.Text) * 0.95
ElseIf Val(Text1.Text) > 400 And Val(Text1.Text) <= 600 Then

Text2.Text = Val(Text1.Text) * 0.9
ElseIf Val(Text1.Text) > 600 And Val(Text1.Text) <= 1000 Then

Text2.Text = Val(Text1.Text