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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populating a listbox from array (Multiple Columns)

Status
Not open for further replies.

gal4y

Technical User
Dec 24, 2001
72
US
I would like to take three single dimensional arrays and populate a listbox on a form. Each array should fill one column.

I got this code off line and it doesn't work either.
Code Below.

Not sure what I am doing wrong. I have used the additem, column and rowsource properties.

Dim MyArray() As Double
ReDim MyArray(3, 6)
Dim i As Single

List1.ColumnCount = 3 'The 1st list box contains 3 data columns

'Load integer values into first column of MyArray
For i = 0 To 5
MyArray(i, 0) = i
Next i

'Load columns 2 and 3 of MyArray
MyArray(0, 1) = "Zero"
MyArray(1, 1) = "One"
MyArray(2, 1) = "Two"
MyArray(3, 1) = "Three"
MyArray(4, 1) = "Four"
MyArray(5, 1) = "Five"

MyArray(0, 2) = "Zero"
MyArray(1, 2) = "Un ou Une"
MyArray(2, 2) = "Deux"
MyArray(3, 2) = "Trois"
MyArray(4, 2) = "Quatre"
MyArray(5, 2) = "Cinq"

List1.ListIndex() = MyArray

Thank you for you assistance in advance
Greg

 
You need to build a RowSource string using these arrays.

GO through each

i.e.

Dim strSource As String
strSource = MyArray(0,0) & ";"
strSource = MyArray(0,1) & ";"
strSource = MyArray(0,2) & ";"
strSource = MyArray(1,0) & ";"

Then remove the final semi-colon and you have a RowSource for your listbox.

Stewart J. McAbney | Talk History
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top