Solved

Listview numeric sort

Posted on 2001-07-10
4
508 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 51

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB6 ListBox Question 4 55
Problem to With line 4 74
Advice in Xamarin 21 109
VBA- How to change font, color and format in outlook e-mail sent from Access 2 115
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

756 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