Solved

ImageList - Run-time error 7: Out of memory

Posted on 2004-09-04
6
301 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
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…
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…

705 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