|
|
Title | Pass a control array to a subroutine as a parameter |
Keywords | control array, parameter, argument |
Categories | Controls, Software Engineering |
|
|
Receive the control array parameter as a Variant array data type. Use LBound and UBound to get its bounds, or use For Each to loop over its elements.
|
|
Private Sub CopyText(ByVal txt As String, dest As Variant)
Dim text_box As TextBox
For Each text_box In dest
text_box.Text = txt
Next
End Sub
|
|
In the main program, simply pass the name of the array without parentheses or an index.
|
|
Private Sub cmdCopy_Click()
CopyText txtSource.Text, txtDestination
End Sub
|
|
|
|
|
|