0

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)

QuantityList.Items.Add(quantity)
MenuitemList.Items.Add(item)
PriceList.Items.Add(price)


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?

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by Smith5646
0

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...

QuantityList.Items.Add(quantity)
MenuitemList.Items.Add(item)
PriceList.Items.Add(price)
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))
        Next

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

Edited by Smith5646: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.