我正在进行课堂作业,用户为每顿饭选择单选按钮。当用户输入忠诚度号码时,我当前遇到了麻烦。该书说,如果用户输入一个忠诚度数字,它会扣除客户所赚取的每10个点的总订单成本的5%。如果客户的忠诚度积分超过订单的全部费用,则客户无法收到款项。
Private Sub btnCalculate_Click(sender As Object,
e As EventArgs) Handles btnCalculate.Click
Dim decCostofMeal As Decimal
Dim decEstimateCost As Decimal
Dim decLoyal As Decimal
Dim decRoastedGarlic As Decimal = 3.99D
Dim decFalafel As Decimal = 5.99D
Dim decBabaganush As Decimal = 7.99D
Dim decChicken As Decimal = 9.99D
Dim decMushroom As Decimal = 6.99D
' If user enter loyalty points '
If radRoastedGarlic.Checked Then
decCostofMeal = decRoastedGarlic
ElseIf RadFalafel.Checked Then
decCostofMeal = decFalafel
ElseIf RadBabaganush.Checked Then
decCostofMeal = decBabaganush
ElseIf RadChicken.Checked Then
decCostofMeal = decChicken
ElseIf RadMushroom.Checked Then
decCostofMeal = decMushroom
End If
decEstimateCost = decCostofMeal
If IsNumeric(txtPoints.Text) Then
decLoyal = Convert.ToInt32(txtPoints.Text)
If decLoyal > 0 Then
decEstimateCost = decEstimateCost - (decEstimateCost * 0.05)
End If
End If
lblResults.Text = decEstimateCost.ToString("C")
lblResults.Visible = True
End Sub
更新 我试图实现一个案例陈述但由于某种原因无法正常工作
If IsNumeric(txtPoints.Text) Then
decLoyal = Convert.ToInt32(txtPoints.Text)
Select Case decLoyal
Case 10 - 19
decEstimateCost = decEstimateCost - (decEstimateCost * 0.05)
Case 20 - 29
decEstimateCost = decEstimateCost - (decEstimateCost * 0.1)
Case 30 - 39
decEstimateCost = decEstimateCost - (decEstimateCost * 0.15)
Case 40 - 49
decEstimateCost = decEstimateCost - (decEstimateCost * 0.2)
Case 50 - 59
decEstimateCost = decEstimateCost - (decEstimateCost * 0.25)
Case 60 - 69
decEstimateCost = decEstimateCost - (decEstimateCost * 0.3)
Case 70 - 79
decEstimateCost = decEstimateCost - (decEstimateCost * 0.35)
Case 80 - 89
decEstimateCost = decEstimateCost - (decEstimateCost * 0.4)
End Select
答案 0 :(得分:0)
要改善案件执行,您需要编写
Case 10 To 19