Listbox Column Sort question

I have a listbox with 4 columns of data.

Two of the columns are character strings
Two are numeric.

Clicking on the header of the numeric columns will sort them.

Doesn’t sort on the string columns.

Is this normal or do I need to do something to cause those two columns to sort.

I have list boxes on other windows that have multiple columns that contain only string data and they sort ok.

(I thought it was a default that clicking on the header would sort the column)

It is. Something in your code or LB design is preventing the sort.

[quote=102119:@Rick Yerex]Two of the columns are character strings
Two are numeric.

[/quote]
There are really no numeric columns in a listbox, the are all strings. So there is something else going on.

If you’re really sorting those columns numerically, then you’ve implemented the CompareRows event. Look there to make sure you’re not returning True for the other columns. A typical mistake is to throw Return True at the end of the event instead of just for the columns you’re handling yourself.

Jim, to clarify then … some columns have words, others have numbers. :wink:

The only thing I’ve done to the columns is set the alignment to center for ONE of the columns with numbers in it.

I can click on the either of the columns with numbers and they will sort corrrectly.

The columns with words don’t sort worth a hoot.

There is no “behind the scenes” code for sorting. The listbox simply displays data from a database table.

Other than setting ColumnCount, Width, Initial Value … the listbox is what it’s standard settings are.

What Jim is saying is with the standard settings, a listbox sort is by string values.
So a list with 1, 3, 100, 20, 300, 2 would be sorted as strings rather than numbers.
as: [1, 100, 2, 20, 3, 300]
not: [1, 2, 3, 20, 100, 300]

You’ll have to manually implement the sort function to get the numbers to sort as numbers.

And please define “don’t sort worth a hoot”. Your initial post indicated they didn’t sort at all. Give some sample data and how it looks before and after sorting.