Iterate thru control sets

Is that possible to iterate thru a control set? I’ve tons of Labels, some of them has the DataField property filled.
I’d like access those. To make it faster I’ve put all of the subject labels to a control set. The control set is called values.
However if I try the following:

for i=0 to UBound(Values) if (values(i).DataField=key) then values(i).Text=value end if next i
it doesn’t work. Is there any way to do it like this, or I’ve to iterate thru all controls of the window?

They’re not arrays so you can’t do that
You have to walk through all the controls on the page & see if one isA Values and then do whatever that way
I’m sure if you search the forums you’ll find many threads about this

As Norman suggested, many programmers iterate through all controls and count the ones which are “values” to get the total in the set. I like to keep a separate variable to hold the total number in the set so I know the ubound that way. Whatever works for you.

Or, stick them in an array property of your Window/WebPage when you create them. When you Close them, remove them from the array. Iterate that array,

But you don’t know the ubound - you know the count
You’re first one on the page could be index 9999999 and the next new one could be 65
But there’s only 2

Unless you’re keeping references ? which means this takes up twice as much memory as really necessary
It’s darned quick to spin through all the instances unless you have several thousands of each type on a layout
And if you’ve done that you get all the pain you’ve inflicted on yourself :slight_smile:

I’ve filled a feature request, to add a keys property to control sets.
<https://xojo.com/issue/34294>