Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sorting numeric Listivew column
Message
From
12/12/2000 12:59:21
 
 
To
All
General information
Forum:
Visual Basic
Category:
Coding, syntax & commands
Title:
Sorting numeric Listivew column
Miscellaneous
Thread ID:
00452351
Message ID:
00452351
Views:
54
I need to sort a column in a listview control that holds currency value. I know that all data is treated as characters within listview so straight sorting doesn't work. Thus, I'm using the following code to sort it:

For Each itmX In .ListItems
itmX.SubItems(lngColIndex - 1) = Format$(itmX.SubItems(lngColIndex -
1), "Z0000000000.00;A0000000000.00")
Next itmX

Above code will sort the "positive" currency values correctly but still doesn't sort the negative values correctly. Thus I get:

20.00
10.00
5.00
0.00
-20.00
-10.00
-5.00

Does anyone have a clever way to sort it properly? I'm thinking one way to do it is to copy it to a array/collection, sort it and then place it back in the correct order but this seems to be a lot of work so... TIA.
It's "my" world. You're just living in it.
Reply
Map
View

Click here to load this message in the networking platform