469,126 Members | 1,295 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,126 developers. It's quick & easy.

Listbox

OuTCasT
374 256MB
This is how a person would go about selecting certain values from a listbox that they want to delete from a database.....
usually a person would use this code for say an INVOICE system they were developing....the items would be added to the listbox with a "ADD TO CART" button and then the listbox wld display its productID name and QTY and price of the specific
now to retrieve those values out of the listbox and delte the Qty of each item against the name of each item you would do it like this..

Expand|Select|Wrap|Line Numbers
  1. Dim I As Integer, J As Integer
  2.         Dim Q As Integer, ID As String
  3.  
  4.         For I = 0 To lstCart.Items.Count - 1
  5.  
  6.             J = InStr(lstCart.Items.Item(I).ToString, " ")
  7.             Q = CInt(Mid(lstCart.Items.Item(I).ToString, 1, J - 1))
  8.             ID = Mid(lstCart.Items.Item(I).ToString, J + 1, 6)
  9.  
  10.             'Update products sold
  11.             'find row with correct stock quantity
  12.             Dim PR As Integer
  13.             For PR = 0 To productsTable.Rows.Count - 1
  14.                 If productsTable.Rows(PR).Item("[columnName]").ToString = ID Then
  15.                     Exit For
  16.                 End If
  17.             Next
  18.             productsTable.Rows(PR).Item("[stockColumn]") = CInt(productsTable.Rows(PR).Item("[stockColumn")) - Q
  19.  
  20.         Next I
  21.  
Jan 17 '08 #1
0 831

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

17 posts views Thread by amber | last post: by
3 posts views Thread by Paul T. Rong | last post: by
8 posts views Thread by Oddball | last post: by
6 posts views Thread by Chris Leuty | last post: by
7 posts views Thread by Dave | last post: by
3 posts views Thread by Ali Chambers | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.