List box Indexes

S

Simon Wall

Hi,

I know this will have a simple solution. I have created a
list box on my form, and I want to get each line of the
list box written into an array.

I thought it would be something as simple as

array(n)=me.listboxname(n).value

where n would be the list index. It doesn't work though,
is it a syntax error or is it more difficult than this


Hope you can help

Cheers

Simon
 
S

Sandra Daigle

You can use either the Column property (which will allow you to get a value
from any of the columns in the listbox) or the ItemData property, which will
only return the value in the bound column.

Dim strArray() As String
Dim strArrayB() As String
Dim intI As Integer
ReDim strArray(Me.Liste.ListCount)
ReDim strArrayB(Me.Liste.ListCount)
For intI = 0 To Me.Liste.ListCount
' Get the value from the 2nd column of row intI
strArray(intI) = Me.Liste.Column(1, intI)
' Get the value from the bound column of row intI
strArrayB(intI) = Me.Liste.ItemData(intI)
Next intI

I am curious though, why are you moving it to an array? You might be able to
just work with the data in the listbox and skip the array entirely.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top