0

有2个lisbox。第一个包含零售产品的价格,第二个包含零售产品的数量。

在此处输入图像描述

用户可以根据需要添加任意数量的项目。所以物品的数量不受限制。我希望在添加新项目时**,**代码自动计算总现金。通过将数量列表中的所有项目相乘并添加它们。提前致谢。

4

1 回答 1

1

最简单的解决方案是循环包含价格的列表框。数量指数等于价格指数。正确的?

' this holds the value for the total amount
Dim totalAmount As Integer = 0
' loops the listbox to all items
For a As Integer = 0 To ListBox1.Items.Count - 1
     totalAmount = totalAmount + (CInt(ListBox1.Items(a).ToString) * CInt(ListBox2.Items(a).ToString))
Next
MsgBox(totalAmount)
于 2012-09-14T15:03:57.580 回答