Solved

ImageList - Run-time error 7: Out of memory

Posted on 2004-09-04
6
314 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
  • 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

829 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