Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass control array to a procedure? 1

Status
Not open for further replies.

MikeCox

Programmer
Jun 4, 2001
340
US
Hi,

Is it possible in VB to pass a control array reference as an argument to a procedure? For example, to pass a standard array you would do this:

Sub Command1_Click()
Dim MyArr(9) as Integer
MyArr(7) = 10
ShowElement MyArr
End Sub

Sub ShowElement(Arr() as Integer)
MsgBox Arr(7) 'Displays 10
End Sub

But when I Dim MyArr(9) as TextBox, and update the argument ShowElement is expecting, the ShowElement call raises the error: Type Mismatch, Array or UDT expected. I've tried several variations of this to no avail (including passing the first element in the array). I'm currently looking into declaring a module level array of dummy textboxes, and set them to the text box array I want the sub to work with just before the procedure call, but I'm not sure that will work either. Is it possible to pass a control array to a procedure this way, and if so, what is the proper syntax?

Thanks!

-Mike

Difference between a madman and a genius:
A madman uses his genius destructively,
A genius uses his madness constructively.
 
Thanks John! Difference between a madman and a genius:
A madman uses his genius destructively,
A genius uses his madness constructively.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top