Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > control arrays again


Reply
 
Thread Tools Display Modes
  #1  
Old 06-08-2007, 08:59 AM
Panoy's Avatar
Panoy Panoy is offline
Junior Contributor
 
Join Date: Jan 2007
Location: Iloilo City, Philippines
Posts: 204
Default control arrays again


Hi to all,

I am using many textboxes in a given form and I made them all in a control array.
Is it possible to pass control arrays in a procedure or function? If it is possible, maybe any of you can give examples or even just clues.

Thanks and god bless all!
__________________
Programming is fun!
Reply With Quote
  #2  
Old 06-08-2007, 09:44 AM
Cerian Knight's Avatar
Cerian Knight Cerian Knight is offline
Multi-Technologist

Super Moderator
* Expert *
 
Join Date: May 2004
Location: Michigan
Posts: 3,739
Default

This is simple enough to demonstrate the concept:
Code:
Private Sub Command1_Click()
Call MySub(Text1) 'Text1 is the name of a control array
End Sub

Private Sub MySub(MyControl As Object)
Dim ctrl As Object
For Each ctrl In MyControl
    Debug.Print ctrl.Text
Next
End Sub
Reply With Quote
  #3  
Old 06-08-2007, 11:18 AM
Panoy's Avatar
Panoy Panoy is offline
Junior Contributor
 
Join Date: Jan 2007
Location: Iloilo City, Philippines
Posts: 204
Default

thanks, how about changing the data type of the MyControl argument? Instead of using the Object Data Type, can I use the Textbox object?
Quote:
Private Sub MySub(MyControl as Textbox)
__________________
Programming is fun!
Reply With Quote
  #4  
Old 06-08-2007, 12:02 PM
Cerian Knight's Avatar
Cerian Knight Cerian Knight is offline
Multi-Technologist

Super Moderator
* Expert *
 
Join Date: May 2004
Location: Michigan
Posts: 3,739
Default

Quote:
Originally Posted by Panoy View Post
...can I use the Textbox object?
Not in that way, because the TextBox object cannot reference an array.
You could 'Dim ctrl As TextBox', however.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->