Solved

Loading images into imagelist in numerical order

Posted on 2006-06-12
4
226 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
Comment Utility

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
Comment Utility


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
Comment Utility
0
 

Author Comment

by:simononz
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now