1
我完全停留在這個課堂上。我有一個計算銷售稅和百分比的程序..但我需要有3個累積文本框;即當用戶輸入他們的小計時,它會保存到一個變量中,然後當他們下一次輸入時,它會將它添加到同一個變量並顯示它。 我一直在這小時並沒有運氣,並不斷收到錯誤。如何累積用戶輸入的值?
Dim numberOfInvoices As Integer
Dim totalOfInvoices As Decimal
Dim invoiceAverage As Decimal
Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
Dim subtotal As Decimal = CDec(txtEnterSubtotal.Text)
Dim discountPercent As Decimal = 0.25D
Dim discountAmount As Decimal = Math.Round(subtotal * discountPercent, 2)
Dim invoiceTotal As Decimal = subtotal - discountAmount
Dim accumSubtotal As Decimal = subtotal
txtSubtotal.Text = FormatCurrency(subtotal)
txtDiscountPercent.Text = FormatPercent(discountPercent, 1)
txtDiscountAmount.Text = FormatCurrency(discountAmount)
txtTotal.Text = FormatCurrency(invoiceTotal)
numberOfInvoices += 1
totalOfInvoices += invoiceTotal
invoiceAverage = totalOfInvoices/numberOfInvoices
Me.txtNumberOfInvoices.Text = numberOfInvoices.ToString
Me.txtTotalOfInvoices.Text = FormatCurrency(totalOfInvoices)
Me.txtInvoiceAverage.Text = FormatCurrency(invoiceAverage)
'-------This is where i've been trying to accumulate values------'
'I need to accumulate the subtotal everytime the user enters something
'txtAccumSubtotal.text = 'the variable that adds evertime a new number is input into txtEnterSubtotal.text
txtEnterSubtotal.Text = ""
txtEnterSubtotal.Select()
'This is a comment
End Sub
希望我在代碼中解釋了這個權利。我真的需要幫助。
謝謝!我知道了。甚至不需要提示:) –