There two ways (only) to create new control ar runtime in VB6:
- using control array (group of controls sharing the same name but having unique indexes)
- using Controls collection
Method 1: control array:
- create one image control in design mode and change its Index property to 0 (zero)
during runtime use similar code (button click lot form_load or whatever):
Code:
Load Image1(Image1.Ubound +1)
Image1(Image1.Ubound).Move SomeLeft, someTop
Set Image1(Image1.Ubound).Picture = LoadPicture("full path goes here")
Image1(Image1.Ubound).Visible = True
Method 2 - controls collection:
Code:
Dim img As Image
Set img = Me.Controls.Add("VB.Image", "imgNew")
Set img.Picture = LoadPicture("full path goes here")
img.Move SomeLeft, someTop
img.Visible = True