0
根據列表框中的項目計算預稅,稅金和總金額。下面是執行時它目前的樣子:使用列表框計算價格
https://drive.google.com/open?id=0B3W0gSES_-fNMmdnU1VTSzR2dFk
這裏是我到目前爲止的代碼:
'load ListBox with test data:
For dblPrices As Double = 1 To 4
lstPrices.Items.Add(dblPrices.ToString("c2"))
Next dblPrices
'calculate pretax total:
Dim dblPretaxTotal As Double = 0
Dim dblSelectedPrice As Double
For intTax As Integer = 0 To lstPrices.Items.Count - 1
lstPrices.SelectedIndex = 0
Dim strPrice As String
strPrice = Convert.ToString(lstPrices.SelectedItem)
Double.TryParse(strPrice, dblSelectedPrice)
dblPretaxTotal = dblSelectedPrice
Next intTax
我只有它編程鈣質,目前顯示的稅前總。它應該顯示$ 10.00。歡迎任何建議。
你沒有問過問題,但如果你想總結一下,你需要積累'dblTotal + = dblSelectedPrice'這個循環沒有讀,它只是每次將'dblPretaxTotal'改爲一個新值。使用調試器來解決這類問題。多數民衆贊成在 – Plutonix
謝謝,我會檢查出來! – htmlbran86
我想回答這個問題,你可以讓它更詳細嗎?你想要發生什麼? –