Dim Dbl1 As Double
Dim Dbl2 As Double
Dim Aux1 As String
Dim qtyadd As String
Dim subtotaladd As String
Dim itm As MSComctlLib.ListItem
Dim i As Integer
Set itm = ListView1.FindItem(txtCode.Text)
If itm Is Nothing Then
ListView1.ListItems.Add , , txtCode.Text
ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , txtproductname.Text
ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , txtqty.Text
ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , txtprice.Text
ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , lbltotal.Text
ElseIf ListView1.ListItems.Item(ListView1.ListItems.Count).Text <> txtCode.Text Then
ListView1.ListItems.Add , , txtCode.Text
ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , txtproductname.Text
ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , txtqty.Text
ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , txtprice.Text
ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , lbltotal.Text
ElseIf Not itm Is Nothing Then
For i = 1 To ListView1.ListItems.Count
If ListView1.ListItems(i).Text = txtCode.Text Then
Dbl1 = (ListView1.ListItems(i).SubItems(2))
Dbl2 = (txtqty.Text)
ListView1.ListItems(i).SubItems(2) = Format((Dbl1 + Dbl2))
'Total
Dbl1 = (ListView1.ListItems(i).SubItems(4))
Dbl2 = (lbltotal.Text)
ListView1.ListItems(i).SubItems(4) = Format((Dbl1 + Dbl2), "###################.00")
Aux1 = "*"
End If
Next i
End If
Sir Help me to Correct this Code the output of this code like this
So if you have.
item1 1
then add item1 again you get
item1 2
also if you have
item2 1
item1 1
and then you add item1 you get
item2 1
item1 2
but, if you have
item1 1
item2 1
then you add another item1, you want
item1 1
item2 1
item1 1
help me sir..