Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to loop through a Listbox 1

Status
Not open for further replies.

bebbo

Programmer
Dec 5, 2000
621
GB
I'm using the command below to add items to a list box. My nItemID number is the recno of a file.

Control.AddListItem(cItem [, nItemID] [, nColumn])

E.G
.lstSales.ADDLISTITEM(PADL(STOCK.DESCR, 30, ' '), RECNO('SELLLINE'), 1)

The listbox can hold any amount of items. Once the items are in there is there a way I can loop through the listbox and get the nItemid number. Something like below:

For nCnt = 1 to .lstsales.listcount
messagebox(.lstsales.list(ncnt)
Endfor

I beleive the above example will give me the Stock.Descr. is there something similar to get the nItemID number?

Thanks
 
Just look at the second column of the collection:
Code:
For nCnt = 1 to .lstsales.listcount
    messagebox(.lstsales.list(ncnt,2))
Endfor
Be aware that what's in the second column had been converted to a character string, so you'll need to take the VAL() of it before you use it like a number.


-BP (Barbara Peisch)
 
Bebbo,

How about this one ?

For nCnt = 1 to .lstsales.listcount
messagebox(alltrim(.lstsales.IndexToItemID(ncnt)))
Endfor


-- AirCon --
 
Oopps, a mistake! It should be like this:

messagebox(alltrim(str(.lstsales.IndexToItemID(ncnt))))


-- AirCon --
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top