Start New Discussion within our Software Development Community

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim quantity As Integer
Dim quanarr(20) As Integer
Dim item As String
Dim price As Double
Dim x As Integer = 0
Dim counter As Integer
counter = QuantityList.Items.Count
quantity = Val(QuantityBox.Text)
item = ItemBox.Text
price = Val(Pricebox.Text)


End Sub
End Class

Here is my code, i have three textboxs that take in a price, item name and quantity. As the user inputs to the text boxes the three are put into their proper listboxes. I need to find a way to correlate the quantity with that certian price. otherwises the total will be wrong. any ideas or help?

I'm not sure when you are trying to total so here are two possible ways.

Create a variable named Total

Dim Total as Double

To keep a running total as things are entered...
After adding the info to the listboxes...

Total += quantity * price

To total everything in the listboxes...

For x = 0 To PriceList.Items.Count - 1
            Total += Val(PriceList.Items(x)) * Val(QuantityList.Items(x))

If that doesn't answer your question, please post more details.

This article has been dead for over six months. Start a new discussion instead.