Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
 
TitlePass a control array to a subroutine as a parameter
Keywordscontrol array, parameter, argument
CategoriesControls, 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
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated