Sorting a Listbox

P

Pegawars

I have a unbound listbox and data is present, i want to sort it. How do
i do that???
 
P

Pegawars

Graham said:
Add an ORDER BY clause to the RowSource query of the listbox.

That's the problem,i filled the list with listbox1.additem Item:=Blabla.

How can i order after that?
 
G

Graham Mandeno

The AddItem method simply appends (or inserts) an item in a string delimited
by semicolons. So if you AddItem "Tom", then "Dick", then "Harry", your
RowSource string will be "Tom;Dick;Harry".

You can use the Split function to morph this string into an array of three
strings, then use your favourite sort algorithm to sort the array, then
finally use the Join function to recreate a delimited string:
"Dick;Harry;Tom".
 

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