0

私は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

私の質問は、コードで何が間違っているのか、探しているものをどのように達成できるのかということです。

4

0 に答える 0