?
Solved

Loading images into imagelist in numerical order

Posted on 2006-06-12
4
Medium Priority
?
237 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
[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
  • 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 750 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
Suggested Courses

650 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