Results 1 to 5 of 5

Thread: Totals go up by one!!

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2002
    Posts
    18

    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

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    probably becasue lstQuanity.SelectedItem and lstCost.selectedItem is returning -1
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3
    Member
    Join Date
    Sep 2002
    Location
    California
    Posts
    52
    Use lstProduct.SelectedIndex to get the values.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Nov 2002
    Posts
    18
    i did that but,it's not deleteing any values

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Nov 2002
    Posts
    18

    Unhappy 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
  •  



Click Here to Expand Forum to Full Width