Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Listbox Sort question

Posted on 2003-02-19
Medium Priority
Last Modified: 2010-04-07
I am trying to order a list of files from a folder and display them in my app in descending order using a listbox is an intermediary to sort the files quickly. The problem is that all the file are created sequentilly in the source app...eg 42_test-1.jpg.
The listbox will sort them no problm until we reach the number 10 (after the dash), where it is sorted to occur right after the 1.

Is there another way to name the files to make sorting easier or is there another type of sort i should use?
Thanks in advance
Question by:Winston Smith

Accepted Solution

bob_online earned 200 total points
ID: 7983881
It's sorting the numbers as characters.  you may need to name the files like "01_test1.jpg", "02_test1.jpg", etc so that the numerical part always has the same number of digits OR parse out the number part and sort only on that, i.e.

Val(Left$(strFileName, Instr(strFileName, "_") - 1))

Author Comment

by:Winston Smith
ID: 7984123
Sweet ... always takes a fresh mind after staring at the code for hours. Worked like a charm after padding the beginning of the identifier with zero's to always make it four digits long.
Thanks bob

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

564 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