i'm using CreateDIBSection():

Public Function NewImage(ByVal ImageWidth As Long, ByVal ImageHeight As Long, Optional color As ColorConstants = vbBlack) As Long
    If (Width > 0 Or Height > 0 Or hBitmap > 0 Or PointerPixelData > 0) Then DeleteImage
    Width = ImageWidth
    Height = ImageHeight

    'Criar HDC

    MemoryHDC = CreateCompatibleDC(0)

    With bmiInfo.bmiHeader
        .biSize = Len(bmiInfo.bmiHeader)
        .biWidth = Width
        .biHeight = -Height ' is negative for start on top left pixel image
        .biPlanes = 1
        .biBitCount = 32
        .biCompression = BI_RGB
        .biSizeImage = AlignScan(bmiInfo.bmiHeader.biWidth, bmiInfo.bmiHeader.biBitCount) * bmiInfo.bmiHeader.biHeight
    End With
    If MemoryHDC = 0 Then MsgBox "error: HDC not created!!!"
    hBitmap = CreateDIBSection(0&, bmiInfo, DIB_RGB_COLORS, PointerPixelData, 0&, 0&)
    If hBitmap = 0 Then MsgBox "error: " & GetLastError()
    oldBitmap = SelectObject(MemoryHDC, hBitmap)

    'using pointers:
     ' Get the bits in the from DIB section:

    With tSA
        .fFeatures = FADF_FIXEDSIZE Or FADF_AUTO
        .cbElements = 4
        .cDims = 1
        .Bounds(0).lLbound = 0
        .Bounds(0).cElements = bmiInfo.bmiHeader.biHeight * bmiInfo.bmiHeader.biWidth
        .pvData = PointerPixelData
    End With
     'Erase bDib
    ' Make the bDib() array point to the memory addresses:
    CopyMemory ByVal VarPtrArray(bDib()), VarPtr(tSA), 4
    CopyMemory ByVal VarPtrArray(bDibBGRA()), VarPtr(tSA), 4
    'Clear color
End Function

why, after 4 IDE executions, using CreateDIBSection(), i get, on GetLastError(), 8 : "Not enough memory resources are available to process this command."?
but on EXE i don't get these problem... but why?

Time to retire VB6. Move to something current. Just 2 days ago I nabbed two copies of Visual Studio Pro for 50USD each. Why 2? Office needed more licenses.

VB6 does have limited resources so you will run out on heavy operations.
Read https://www.vbforums.com/showthread.php?902295-how-create-DIB-s too.

Read https://stackoverflow.com/questions/742671/tools-to-identify-memory-hogs-in-vb6-applications about tools to use for find memory hogs and a nice function to see if your app is releasing resources correctly.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.