我没有处理VB。我正在帮助我的母亲完成她的家庭作业,只是不能再思考如何处理这个陈述。
Private Sub btnTotal_Click(sender As Object, e As EventArgs) Handles btnTotal.Click
Dim intPackA As Integer = 0
Dim intPackB As Integer = 0
Dim intPackC As Integer = 0
Dim SavingsPriceB As Decimal = 0.0
Dim SavingsPriceC As Decimal = 0.0
Dim TotalPrice As Decimal = 0.0
lblTotal.Text = String.Empty
If radPackA.Checked Then
TotalPrice = 9.95
lblTotal.Text = TotalPrice
If Integer.TryParse(txtHours.Text, intPackA) Then
If intPackA > 10 Then
TotalPrice = TotalPrice + ((intPackA - 10) * 2)
lblTotal.Text = TotalPrice
End If
End If
If chkSavings.Checked Then
SavingsPriceB = 14.95 + ((intPackB - 20) * 1)
SavingsPriceC = 19.95
If TotalPrice < SavingsPriceB And TotalPrice < SavingsPriceC Then
lblTotal.Text = TotalPrice & ", no savings with Package B or C"
End If
End If
ElseIf radPackB.Checked Then
TotalPrice = 14.95
lblTotal.Text = TotalPrice
If Integer.TryParse(txtHours.Text, intPackB) Then
If intPackB > 20 Then
TotalPrice = TotalPrice + ((intPackB - 20) * 1)
lblTotal.Text = TotalPrice
End If
End If
If chkSavings.Checked Then
End If
ElseIf radPackC.Checked Then
TotalPrice = 19.95
lblTotal.Text = TotalPrice
End If
If chkNonprofit.Checked Then
TotalPrice = Format((TotalPrice - ((TotalPrice / 100) * 20)), ".00")
lblTotal.Text = TotalPrice & ControlChars.CrLf & "Non-Profit Organization discount applied"
End If
End Sub
这是给我问题的If chkSavings.Checked
。
这是设计的程序。包裹旁边有一个标签显示总数。
选中Potential Savings
后,如果您使用其他套餐,还应显示可以节省的金额。
因此,如果我提出Package A, 5 hours, 20% discount
,则应该说$7.96, no savings with Package B or C
。对于Package A, 25 hours
,应该说$39.95, save $20.00 with Package B, and save $20.00 with Package C
我的代码即使是第一部分也不会打印出来。
Package A and less then 10 hours = $9.95, every additional hour is $2.00 more
Package B and less then 20 hours = $14.95, every additional hour is $1.00 more
Package C with unlimited hours is = $19.95
所以我的问题是,我在代码中做错了什么,或者我怎样才能实现我想要的东西。