need help with this pleeeeeeez


i'm trying to search for an exsiting item in lstBox when 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
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories