Image Control Resizing

I'm using an array of Images controls that are loaded at run time from 0-99.  I want all of them to resize to the window in a 10 by 10 square when the window is resized, but they don't.  I think that this is because the stretch property is set to True.  Here is the code:

Private Sub Form_Resize()
    On Error Resume Next
    For I = 1 To H * W
        Unload MazPiece(I)
    Next I
End Sub

Public Sub MakeBoxes()
    A = ToolBar(8).Left + ToolBar(8).Width + 500 'Left Buffer
    WID = (Me.Width - A - 400) / W
    HEI = (Me.Height - 900) / H
    MazPiece(0).Height = HEI
    MazPiece(0).Width = WID
    MazPiece(0).Visible = True
    For I = 1 To H * W
        Load MazPiece(I)
        MazPiece(I).Width = WID
        MazPiece(I).Height = HEI
        MazPiece(I).Visible = True
    Next I
    Whatever = 0
    For Y = 1 To W
        For X = 1 To H
            Whatever = Whatever + 1
            MazPiece(Whatever).Left = ((X - 1) * WID) + A
            MazPiece(Whatever).Top = ((Y - 1) * HEI)
            MazPiece(Whatever).Picture = PicClip.GraphicCell(14)
        Next X
    Next Y
End Sub
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hi VBTom,
  I think I found the answer.
When I tried a code that is pretty the same like yours, I found that I cannot Unload objects that are placed on the form during the Form_Resize or Form_Paint events.
 So the Unload cicle in your Form_Resize event doesn't do anything and the On Error Resume Next make's it jump over without sending an error.
 So if you remove the statement On Error Resume Next, an error should appear. (Yes?).
  So I recommend when resizing the form, do not Unload any objects.
 Just make them invisible:

Then in MakeBoxes change their coordinates and Width and Height
  ImageX.Left= ...
  ImageX.Top= ...
  ImageX.Width= ...
  ImageX.Height= ...

  just make all the Images visible:


You'd better use the Load ImageX statement in your Form_Load event.
Do not use Load or Unload statements in
your Form_Resize or Form_Paint events.

Use the Visible=True, Visible=False
property instead.

             Pavel Tsekov
          email :

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
VBTomAuthor Commented:
Thank you.  It worked just like I wanted it to.  I also found another answer that does the same thing elsewhere.  That answer is to make ImageX.Picture = LoadPicture("").  They both do the same thing though I'm not sure which one is faster.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.