
Passing Control Arrays to Sub-Procedures
Jud,
You need to use a variant as the control array argument in the subprocedure
or function header.
As an example, place some textboxes on a form. The textboxes should all be
members of a control array. Add a command button to the form. In the
command button's click event, call a subprocedure named PrintText and pass
the subprocedure the control array of textboxes:
Private Sub Command1_Click()
PrintText Text1()
End Sub
Create a subprocedure named PrintText that can accept the control array:
Private Sub PrintText(myControlArray As Variant)
Inside the subprocedure, loop through all the controls in the array,
displaying the text for each control in a message box:
Dim counter As Long
For counter = myControlArray.lbound To myControlArray.ubound
MsgBox myControlArray(counter).Text
Next counter
Hope this helps,
Kerry Moorman
Quote:
>Hey ppl,
>This may sound stupid, but I cannot remember how to pass a control array to
>a sub-procedure in VB. Could someone post an example of the Sub definition
>and proc call please? It would be appreciated.
>Jud.