[RESOLVED] Pass Control Array into Sub
Hi, I'm making my own Subroutine where I'm passing in a control array of pictureboxes but I'm lost as to how to do it. The picturebox name will change, I have many control arrays of pictureboxes on my form. I thought something like this.
Code:
Sub MySub(ByRef picBox1() as PictureBox)
'Code
End Sub
and calling it like this:
Code:
For X = 1 to 4
Call MySub(picBox1(X))
Next X
But that doesn't work...Anyone know how to do this?
Re: Pass Control Array into Sub
the problem is, you are passing in a SINGLE picturebox.. not the array
but i cant remember how to make the sub accept it.. unless its a variant
VB Code:
Sub MySub(pbx1 As Variant)
For x = 0 To pbx1.ubound
Debug.Print pbx1(x).Index
Next
End Sub
Private Sub Command1_Click()
MySub Picture1
End Sub
Re: Pass Control Array into Sub
I think that
Sub MySub(pbx1 As Object)
would be better.
Re: Pass Control Array into Sub
Thanks, that worked great!