Results 1 to 2 of 2

Thread: some help plzzz?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2002
    Posts
    18

    Unhappy some help plzzz?

    i'm trying to search for an exsiting item in lstBox, b4 i add any new ones. if there's the same item in lstBox than just add Quantity, if no then add the item. my code here is not working, so i would like u to check out . also i'd like to delete quanity by inputting a (-) number in txtQuantity.text, how can i do that.


    Private Function IsFound(ByVal pstrSearch As String) As Boolean
    Dim itemCount As Integer
    For itemCount = 0 To lstProduct.Items.Count - 1
    'If LCase(pstrSearch) = LCase(lstProduct.Items.Item(itemCount)) Then
    If lstProduct.Items.Item(itemCount) Is (cobProduct.SelectedItem) Then
    IsFound = True
    Exit Function
    End If
    Next
    IsFound = False
    End Function

    Private Sub cmdAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAdd.Click
    Dim itemFound As Boolean
    Dim itemCount As Integer
    If cobProduct.SelectedIndex <> -1 Then

    If txtQuantity.Text = "" Then
    MsgBox("please choose a quantity 1 or above")
    Else
    If IsNumeric(txtQuantity.Text) = False Then
    MsgBox(" please insert a number")
    Else
    quantity = CDbl(txtQuantity.Text)
    If IsFound(cobProduct.Text) = False Then
    ' item not found in lstProduct
    MsgBox(" not found")

    If quantity > 0 Then

    lstQuantity.Items.Add(quantity)

    totalQuantity = Val(lblTotalQuantity.Text) + quantity
    lblTotalQuantity.Text = CStr(totalQuantity)


    lstProduct.Items().Add(cobProduct.Text)
    calculation = CDec(Val(txtQuantity.Text) * Val(lblUnitPrice.Text))
    lstCost.Items.Add(calculation)
    totalCost = (totalCost + calculation)
    lblTotalCost.Text = CStr(totalCost)
    Else
    lstQuantity.Items.Add(lstProduct.SelectedIndex)
    lstCost.Items.Add(lstProduct.SelectedIndex)
    End If


    Else
    MsgBox("please input a quantity more than 0")
    End If

    End If


    End If
    Else
    MsgBox("please select an item")


    End If
    txtQuantity.Text = ""
    txtQuantity.Focus()

    End Sub

    thanks

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    What are the Items you are using in the listbox? Strings? Objects?

    Try using the ListBox.Items.Contains method. It should return True or false if the item is in there.

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