Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / COM / May 2004



Tip: Looking for answers? Try searching our database.

passing control arrays to a sub

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Miguel Martinez - 27 May 2004 23:17 GMT
how do I pass a whole control array to a sub? is there a way to do this
in Visual Basic 6? any help will be nice, thanks in advance.

Miguel Martinez
Ken Halter - 28 May 2004 15:28 GMT
> how do I pass a whole control array to a sub? is there a way to do this
> in Visual Basic 6? any help will be nice, thanks in advance.
[quoted text clipped - 3 lines]
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!

Control arrays need to be passed as Object. If you start a new project,
create a control array of textboxes called Text1(0-n) and drop a command
button on the form, you'll see one way of doing it.
'===========
Option Explicit

Private Sub Command1_Click()
   Call SetColors(Text1)
End Sub

Private Sub SetColors(AControlArray As Object)
   Dim o As TextBox
   'Set the back color
   For Each o In AControlArray
      o.BackColor = RGB((Rnd * 127 + 128) _
         , (Rnd * 127 + 128), (Rnd * 127 + 128))
      o.ForeColor = RGB(Rnd * 127, Rnd * 127, Rnd * 127)
   Next
End Sub
'===========

Signature

Ken Halter - MS-MVP-VB - http://www.vbsight.com
Please keep all discussions in the groups..

Miguel Martinez - 28 May 2004 17:38 GMT
thanks, I've done a test five minutes ago and it seems to work, you save
me a lot of work of typing a lot of code.
you're the best!!

Miguel Martinez
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.