Solved

ImageList - Run-time error 7: Out of memory

Posted on 2004-09-04
6
305 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
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…

867 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

22 Experts available now in Live!

Get 1:1 Help Now