QTY-QUANTITY
The Price is not increasing.
I want to multiply the QTY to PRICE , when QTY is Increasing The PRICE need to increase to depends on the QTY.

 Private Sub clickMe(sendr As Object, ByVal e As EventArgs)
        Dim btn As Button = CType(sendr, Button)
        Dim ProdMatch As Boolean = False
        For i As Integer = 0 To lvorder.Items.Count() - 1
            If lvorder.Items(i).SubItems(1).Text = btn.Text Then
                lvorder.Items(i).Text = (Val(lvorder.Items(i).Text) + 1).ToString
                ProdMatch = True
                Exit For
            End If
        Next
        If Not ProdMatch Then
            'Add the item at first time
            Dim item As ListViewItem
            item = lvorder.Items.Add("1")
            item.SubItems.Add(btn.Name)
            item.SubItems.Add(Val(item.SubItems(0).Text) * btn.Tag.ToString())
            lblstotal.Text = "0.00"
        End If
        txtcash.Text = ""
    End Sub

What I think that you need an another column for rate. In your memo, you must inclde a column for rate of a single unit. The columns should be
Qty-------Name of Dish-----------Rate------------Price

So everytime, when you have tried to insert/increase a Qty of a product multiply QTY with rate to get the price, Price = Qty * Rate.

@Shark 1, what is Rate stands for?

Rate stands for the price of a single unit.

If Qty=4 and Rate=10.00 then Price = Qty * Rate = 4 * 10.00 = 40.00

i tried this code beacuse i got confused how to declare the Price.

            Dim item As ListViewItem
            Dim Rate As Integer = btn.Tag
            item = lvorder.Items.Add("1")
            item.SubItems.Add(btn.Name)
            item.SubItems.Add(Rate)
            item.SubItems.Add(Val(item.SubItems(0).Text) * Rate.ToString()) 'this is supposed to be the price
            lblstotal.Text = "0.00"

help me please,i really got confused all of the sudden

If you are calculating the tootal price for each dish you need to know

  1. the quantity
  2. the price per unit (the rate)

Your table only has columns for

  1. the quantity
  2. the name of the dish
  3. the total price

You need to add a column indicating the cost (rate) of the dish.

i add another column
qty[quantity], name of dish, rate, total price
listview[lvorder]
the qty is in the 1st column of lvorder
and the rest are sub items
btn.tag [is the price per unit]

 dim rate as integer = btn.tag
 dim Totalprice as integer = rate * lvorder. 'i got confused here, this should be the 1st column of lvorder'
 dim item as listviewItem
 item = lvorder.Items.Add("1") 'QTY
 item.SubItems.Add(btn.Name)   'Name of Dish
 item.SubItems.Add(Rate)       'Rate
 item.SubItems.Add(totalprice)

is my code right?

Why have you confused about the difference between rate and Total Price ?
Rate = Price per Unit/dish
Total Price= Qty * Rate
When a product is introduced first time to the list your codes should be

 Dim item as listviewItem
 item = lvorder.Items.Add("1")                  'QTY
 item.SubItems.Add(btn.Name)                    'Name of Dish
 item.SubItems.Add(btn.tag)                     'Rate
 item.SubItems.Add((1 * Val(btn.tag)).ToString) 'Total Price

And when you have added the next Qty for that product the codes should be

For i As Integer = 0 To lvorder.Items.Count() - 1
    If lvorder.Items(i).SubItems(1).Text = btn.Text Then
        lvorder.Items(i).Text = (Val(lvorder.Items(i).Text) + 1).ToString
        lvorder.Items(i).Subitems(3).Text = (Val(lvorder.Items(i).Text) * Val(lvorder.Items(i).Subitems(2).Text)).ToString 'for Total Price
        ProdMatch = True
        Exit For
    End If
Next

@Shark_1, sorry about that, im not really confused of rate and total price , im confused of how should i declare the total price like totalprice= rate* lvorder.
i think i've made it complicated without analyzing how should it works. Im totally sucks in calculation when it comes to vb.net. But thank you again. :)

it works now. thank you

Hi again. I'm sorry if i trouble you again, but the qty is now working, the problem now is the total price
whenever i tried to increase the qty of one item the total is not updating/adding . ive used the code above, i tried something but it's still not working.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.