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:Halon
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

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

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

Independent Software Vendors: 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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
Suggested Courses
Course of the Month15 days, 8 hours left to enroll

741 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