Solved

Loading images into imagelist in numerical order

Posted on 2006-06-12
4
230 Views
Last Modified: 2010-04-30
Hi

I have a directory full of images:

1.bmp
2.bmp
3.bmp
...

What would be the easiest way to get them loaded into an imagelist in numerical order?

reading them in normally I get them in the following order:
1.bmp
11.bmp
12.bmp
...
2.bmp
20.bmp
..

etc

Should I just read in the file names into a list, sort them numerically then load them into the imagelist.

I also just cant use the lowest and highest as there could be breaks in the numbers, i.e. they wont be from just 1 - 100, they could be: 1 5 7 11 12 13 15 17 etc.

Working code would be nice,.

Cheers
Simon
0
Comment
Question by:simononz
  • 2
4 Comments
 
LVL 13

Expert Comment

by:Mark_FreeSoftware
ID: 16892532

what you could do, is to point a filelist to the directory where they are stored.

then create a loop from the minimum value (i assume this is 1) to the max value

now look at every number if that one is available in the list
0
 
LVL 13

Expert Comment

by:Mark_FreeSoftware
ID: 16892564


and this is a working example:

you need one filelistbox (file1)
and two listboxes(list1 and list2)


Option Explicit

Private Sub Form_Load()
Dim n As Long
   File1.Path = App.Path          'change this to the bmp path!
   For n = 0 To File1.ListCount
      List1.AddItem LCase(File1.List(n))
   Next
   
   For n = 1 To 100               'change 100 to the max possible value!
      List1.Text = CStr(n) & ".bmp"
      If List1.Text <> "" Then   'this is not possible fith a filelist so i put it in a normal list
         List2.AddItem List1.Text
      End If
   Next
End Sub
0
 
LVL 26

Accepted Solution

by:
EDDYKT earned 250 total points
ID: 16893185
0
 

Author Comment

by:simononz
ID: 16900129
Thanks for the pointers. Straight rip of the code from vbnet did the trick.

Now that you mention it I am sure I had seen it before.

Thanks for the input.

Simon
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

856 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