multiple listbox items

vbnow
05-31-2002, 11:26 AM
I have a standard listbox that instead of only one item per line I have 3 items per line such as: Quantity, ItemNum, Price. I want to add these items to their matching columns in my database of quantity, ItemNum, and Price.

Is there a column property of the listbox that I can use to extract the Items individually?


rs is my recordset

Do while rs.Eof = False
list1.addnew = rs!Quantity
Loop

This only gets one item per line.

Phoebe
05-31-2002, 12:06 PM
Interesting. Have you got them to appear in the correct format?

Is there any reason why you don't want to use mshflexgrid or datagrid? With grids, you can code a click event sub which will do stuff after the user has selected them.

Anyways, here is I think how I would code your problem:

1. Declare a dynamic array
2. After you have obtained your recordset, redim array to (0 to recordcount - 1, 0 to 2)
3. Populate the array


Dim intCounter as integer

Do while rs.Eof = False
array(intCounter, 0) = 1st column
array(intCounter, 1) = 2nd column
array(intCounter, 2) = 3rd column

intCounter = intCounter + 1
rs.movenext
Loop


4. Display the data in the listbox based on the array


For intCounter = lbound(array) to ubound(array)
listbox.additem array(intCounter, 0)
next

For intCounter = lbound(array) to ubound(array)
listbox.additem array(intCounter, 1)
next

For intCounter = lbound(array) to ubound(array)
listbox.additem array(intCounter, 2)
next



Not really easy, but it will work, I think. Do let me know how you format your listbox to show everything correctly.

reboot
05-31-2002, 12:23 PM
See This Thread (http://www.visualbasicforum.com/showthread.php?s=&threadid=25847&highlight=LBSETTABSTOPS) for an example of setting tabstops (for multiple columns) in a standard listbox.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum