We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,047 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Help Adding and Multiplying in listboxes

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
1 Day
Discussion Span
3 Years Ago
Last Updated
2
Views
c.pentasuglia
Light Poster
38 posts since Nov 2009
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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.

Smith5646
Junior Poster in Training
65 posts since Nov 2009
Reputation Points: 34
Solved Threads: 9
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0520 seconds using 2.65MB