Solved

Listview numeric sort

Posted on 2001-07-10
4
502 Views
Last Modified: 2007-12-19
Hi, I have two columns in my listview control, one a string and one a number. I have coded it so it is sorted on the click event of the column header. How do I get the number field to sort numerically instead of as a string?
Thanks
0
Comment
Question by:TurnerP
4 Comments
 
LVL 38

Expert Comment

by:PaulHews
ID: 6269074
If you format your numbers with enough leading zero's the alphabetical sort will do:

For 0 to 999--

Format(intNum, "000")

000
001
002
...
999
0
 
LVL 50

Expert Comment

by:Ryan Chong
ID: 6269075
Hi TurnerP,

Sorting ListView ListItems Using Callbacks: http://www.mvps.org/vbnet/code/callback/lvsortcallback.htm

'Hope will help.
0
 
LVL 1

Accepted Solution

by:
Sieger earned 50 total points
ID: 6269294
Here's an article/sample code from a guru for sorting by number or date.  He put the code inside the columnheader click event. but it's very easy to make it a procedure.

http://www.codeguru.com/vb/articles/1818.shtml
0
 

Author Comment

by:TurnerP
ID: 6269618
Thanks, I found this very helpful.
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Validating VB6 Function 19 59
Paint/Redraw window while dragging 16 77
VB6 - Convert HH:MM into Decimal 8 54
Error with a code discussed on this page 5 14
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question