我想做的是将项目添加到列表框中,文本框将自动更新。我已完成此操作,可以添加价格,但仅对于数量1,如果我添加1个项目的数量超过1个,将仅计为数量1个项目的价格,如何解决?
count = Math.Round(qty_of_item, 2) * (product_price)
lblprice.Text = (" Rm " & count)
ListBox1.Items.Add(product_name)
ListBox4.Items.Add(product_class)
ListBox5.Items.Add(product_size)
ListBox3.Items.Add((" " & Math.Round(qty_of_item)))
ListBox2.Items.Add(FormatCurrency(count))
caculate = count
total = 0
Dim price As Decimal = 0
price = total + caculate
For i As Integer = 0 To ListBox2.Items.Count - 1 'get the item count inside listview
price = (CDec(ListBox2.Items(0).ToString())) 'get the value of item of each item in each listbox row
total += price 'add price into total
Next
txtsubtotal.Text = FormatCurrency(total)
gst = total * 0.06
txtgst.Text = FormatCurrency(gst)
total_after_gst = total + gst
txtfinaltotal.Text = FormatCurrency(total_after_gst)
Else
MessageBox.Show("Qty value cant be empty And only allow Integer", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error)
End If
更新
这仍然无法解决
你必须使用price
代替caculate
的For - Next loop
For i As Integer = 0 To ListBox2.Items.Count - 1 'get the item count inside listview
price = CDec(ListBox2.Items(i)) 'get the value of item of each item in each listbox row
total += price 'add price into total
Next
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句