VB题目,选择结构

2025-02-24 03:22:12
推荐回答(3个)
回答1:

Private Sub Command1_Click()
If Trim(Text1.Text) = "" Then
MsgBox "正确填写数据"
Exit Sub
End If
a = Val(Text1.Text)
If a < 1000 Then b = a: s = "实付款"
If a >= 1000 And a < 2000 Then b = a * 0.9: s = "按商品价9折付款"
If a >= 2000 And a < 3000 Then b = a * 0.8: s = "按商品价8折付款"
If a >= 3000 Then b = a * 0.7: s = "按商品价7折付款"
Label1.Caption = Format(b, "0.00")
Label2.Caption = s
End Sub

Private Sub Form_Load()
Label1.Caption = ""
Label2.Caption = ""
Text1.Text = ""
End Sub

回答2:

Private Sub Command1_Click()
Dim dblA As Double
Dim dblB As Double

dblA = Val(Text1.Text)

If dblA = 0 Then
MsgBox "输入的金额不能为空"
ElseIf dblA < 1000 Then
dblB = dblA
ElseIf dblA >= 1000 And dblA < 2000 Then
dblB = dblA * 0.9
ElseIf dblA >= 2000 And dblA < 3000 Then
dblB = dblA * 0.8
ElseIf dblA >= 3000 Then
dblB = dblA * 0.7
End If

Text2.Text = dblB

End Sub

回答3:

写好了,直接把工程传给你。。。。