|
-
Dec 2nd, 2002, 10:47 AM
#1
Thread Starter
Junior Member
Totals go up by one!!
i've got the code below... my prob. is when i remove a quanitity or cost from their lstBoxs, the totals should be subtracted from that quantity or cost. but instead both totals go up by one???
no idea why
Private Sub cmdRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdRemove.Click
If lstProduct.SelectedIndex <> -1 Then
quantity = CDbl(lstQuantity.SelectedIndex)
totalQuantity = Val(lblTotalQuantity.Text) - quantity
lblTotalQuantity.Text = CStr(totalQuantity)
totalQuantity = 0 ' Intialising totalQuantity
totalCost = CDec(Val(lblTotalCost.Text) - lstCost.SelectedIndex)
lblTotalCost.Text = CStr(totalCost)
totalCost = 0 ' initialising totalcost
lstQuantity.Items.RemoveAt(lstProduct.SelectedIndex)
lstCost.Items.RemoveAt(lstProduct.SelectedIndex)
lstProduct.Items.RemoveAt(lstProduct.SelectedIndex)
Else
MsgBox("PLease select an item to be removed")
End If
End Sub
-
Dec 2nd, 2002, 11:10 AM
#2
probably becasue lstQuanity.SelectedItem and lstCost.selectedItem is returning -1
-
Dec 2nd, 2002, 11:18 AM
#3
Member
Use lstProduct.SelectedIndex to get the values.
-
Dec 2nd, 2002, 04:12 PM
#4
Thread Starter
Junior Member
i did that but,it's not deleteing any values
-
Dec 2nd, 2002, 05:56 PM
#5
Thread Starter
Junior Member
any ideas at all??
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|