Sorting a Listbox

  • Thread starter Thread starter Pegawars
  • Start date Start date
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?
 
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".
 
Back
Top