> VB6
> I have a picturebox pic(0) on a form
> I want to pass this control to a sub so that I can create an array of
> pic() using Load.
> How do I pass it as a picturebox?
You can't because that'd be passing a reference to a single control, not the
control array.
> So far I can only pass it as an Object but would like to get full use of
> the picturebox properties etc to appear in the sub.
> Private Sub MenuCreate(pic as Object) ' works but cannot see pic
> properties etc in sub
>
> Private Sub MenuCreate(pic as PictureBox) ' errors out Type Mismatch
> Private Sub MenuCreate(pic as Control) ' errors out Type Mismatch
You're just going to have to pass it as an Object. However, you could
declare a local variable of type PictureBox and assign a specific reference
to that in order to get IntelliSense. Personally though, I don't think it'd
be worth it.

Signature
Mike
Microsoft MVP Visual Basic
Lorin - 29 Jul 2008 18:23 GMT
I did try that but could not figure out how to do the assigment to a
picturebox.
Enlighten me with a little sample code.
> > VB6
> > I have a picturebox pic(0) on a form
[quoted text clipped - 18 lines]
> to that in order to get IntelliSense. Personally though, I don't think it'd
> be worth it.
Jeff Johnson - 29 Jul 2008 21:16 GMT
>> > VB6
>> > I have a picturebox pic(0) on a form
[quoted text clipped - 22 lines]
>> it'd
>> be worth it.
>I did try that but could not figure out how to do the assigment to a
> picturebox.
> Enlighten me with a little sample code.
Private Sub MenuCreate(pic as Object)
Dim newPic As PictureBox
Dim nextIndex As Long
nextIndex = pic.UBound + 1
Load pic(nextIndex)
Set newPic = pic(nextIndex)
' Now you can use newPic for the rest of the Sub and get Intellisense
End Sub
Lorin - 29 Jul 2008 22:37 GMT
OK, I see that. Thanks!
> >> > VB6
> >> > I have a picturebox pic(0) on a form
[quoted text clipped - 39 lines]
> ' Now you can use newPic for the rest of the Sub and get Intellisense
> End Sub