Hi guys,
I have a listview that displays "product Description" in the first column and "Product Price" in another column, after the "add" button is clicked on frmSales form. After that, txtAmountDue is automatically updated with the value of the items added to the listview.
The Remove Button, when clicked, removes the selected item from the listview.
What I want is the code to deduct the value of the item removed from the listview from the Amount in txtAmountDue, when the remove button is clicked.
I have tried to the code below
Private Sub btnRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemove.Click
For ICount = lsv1.Items.Count - 1 To 0 Step -1
If lsv1.Items(ICount).Selected Then
lsv1.Items(ICount).Remove()
Dim pSum As Double
For Each item As ListViewItem In lsv1.Items
pSum -= CInt(item.SubItems(1).Text)
txtAMDue.Text = pSum.ToString("N2")
Next
End If
Application.DoEvents()
Next
End Sub
But instead, is seemingly is deducting the total from the value of the selected item, giving me a negative figure.
May someone help me please.