Solved

ImageList - Run-time error 7: Out of memory

Posted on 2004-09-04
6
322 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
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…
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…

728 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