PDA

Click to See Complete Forum and Search --> : Control Collection


SatheeshTC
Nov 29th, 1999, 10:08 AM
Hi!
I have a collection of controls that i build in the form load.
How do i access each control in it.
The code is like this...

For Each mycontrol in controls
if typeof mycontrol is textbox then
mycollection.add mycontrol
next

Now in mycollection i want to access a control.

Thanks in advance...
satheesg

msdnexpert
Nov 29th, 1999, 05:47 PM
How about this ?

for i=0 to mycollection.controls.count-1
mycollection.control(i).propertyname = propertyvalue
next i

MartinLiss
Nov 29th, 1999, 08:18 PM
msdnexpert may be thinking of something else, but a collection has only 4 properties: Add, Count, Item, and Remove. To access a control you use the Item property and do something like thisFor i = 1 To mycollection.Count
mycollection.Item(i).BackColor = 1234
Next i
Note that while most VB things are 0-based a collection is 1-based.

------------------
Marty

[This message has been edited by MartinLiss (edited 11-30-1999).]