
Create Object at Runtime Help
Firstly, place an imagebox on your form and set the picture for it. Then
set the 'Index' property of the imageBox control to 0.
This will enable you to create the 'base' of the array. Once you've done
that the following code will create the extra elements of the array for
you. Be sure to always unload the array element once you've finished with
it.
You can set the properties for each element of the array seperately from
the original.
I've offset the created images so that they're not placed on the top of
the original.
I hope this helps ...
Option Explicit
Dim i As Integer
Dim NumOfImages As Integer
Private Sub cmdLoadArray_Click()
NumOfImages = 3
For i = 1 To NumOfImages
Load Image1(i)
Image1(i).Left = Image1(i - 1).Left + Image1(i - 1).Width
Image1(i).Visible = True
Next i
End Sub
Private Sub cmdUnloadArray_Click()
For i = 1 To NumOfImages
Unload Image1(i)
Next i
End Sub
Quote:
> I'm wanting to add objects into a control array. The Image object to
> be exact. Let's say I had "Image1(0)" I was working with. And when I
> clicked a button, POOF! Suddenly I have an additional Image object.
> "Image1(1)" to be exact. Now... How do I accomplish this?
> Anyone have any code I can see that explains this?
> And...how do I "delete" the object at runtime if I'm done with it?
> Paul