Solved

ImageList - Run-time error 7: Out of memory

Posted on 2004-09-04
6
319 Views
Last Modified: 2008-01-09
When I try to load into an ImageList more then 9 pictures, I get the "Run-time error 7: Out of memory". All pictures are bmp format.
my code:
For i = 0 To 10
    picName = PictureName(i)
    Set imgX = ImageList1.ListImages.Add(i + 1, picName, LoadPicture(App.Path & "\..\pics\" & picName))
Next i


thanks.
0
Comment
Question by:pakci
[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
  • 4
  • 2
6 Comments
 
LVL 7

Expert Comment

by:Burbble
ID: 11981982
I couldn't recreate this error, even with For i = 0 to 100 it still worked fine.

Could you post the code to the PictureName() function?

Thanks

-Burbble
0
 

Author Comment

by:pakci
ID: 11984846
I'm attaching the PictureName() function, but I don't think this is the problem - When I reduced the loops to 9 it worked good.

Private Function PictureName(index As Integer) As String
Dim name As String
Dim suit As Integer
   
    suit = index \ 13
   
    Select Case suit
        Case 0: name = "G"
        Case 1: name = "R"
        Case 2: name = "Y"
        Case 3: name = "B"
        Case 4: name = "S"
    End Select
   
    If index Mod 13 <= 13 Then
        name = name & ((index Mod 13) + 1)
    End If

    PictureName = name + ".bmp"
End Function
0
 
LVL 7

Expert Comment

by:Burbble
ID: 11985197
Hmm, I don't know... Here's some things you might try:

    Set imgX = ImageList1.ListImages.Add(i + 1, picName, LoadPicture(App.Path & "\..\pics\" & picName))

change to

    ImageList1.ListImages.Add i + 1, picName, LoadPicture(App.Path & "\..\pics\" & picName)

or

    ImageList1.ListImages.Add i + 1, Left$(picName, Len(picName) - 4), LoadPicture(App.Path & "\..\pics\" & picName)

Otherwise, since they are Bitmaps, they may just be taking up too much memory for it to handle (especially if they are very large), although I don't know why only 10 images would be doing this...

-Burbble
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 

Author Comment

by:pakci
ID: 11985397
Ok, I found the problem.
I tryed to define the ImageHeight to 1440 and the ImageWidth to 1065 in the properties.
How can I do it by code?
0
 
LVL 7

Accepted Solution

by:
Burbble earned 100 total points
ID: 11986053
1440x1065 is a gigantic image, especially for a 24-bit bitmap (about 4.4MB in size). I don't think the control can handle it. You may have to resize the images as you retrieve them from the ImageList for use in your program.

-Burbble
0
 
LVL 7

Expert Comment

by:Burbble
ID: 11991896
Sorry I couldn't give an exact solution, I just don't think it can handle images that big :/

Thanks for the points, and good luck

-Burbble
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Suggested Solutions

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…

730 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