Finding the number of items in a Control Set

Greetings all,

Is there a simple way of referencing a Control Set? Specifically a way of finding the number of elements within. (Like a UBound property).

Thanks :slight_smile:

Loop through all the controls and collect the highest index where the name matches. Note that there may be gaps, so highest index may be different than count.

Thanks Tim, but is there a way to loop through (not knowing the length) without getting a nilObject?

This is what was trying - perhaps I am missing an alternate way of looping through.

For i=0 to <length of myControlSet>
myControlSet(i).doSomething
Next

There doesn’t seem to be an obvious way to find . The “for each” doesn’t work with ControlSets and Control Sets don’t have a UBound like a typical array.

you missed one important word in Tim’s response “loop thru ALL the controls”

Dim ctrl As control
  For i=0 To Me.ControlCount-1
    ctrl=Me.control(i)
    If ctrl.Name="whatever_name" Then
       If ctrl IsA Label Then // replace LABEL with whatever type of control you are looking for
     ' check the desired attrbutes
' you WILL need to cast it to correct type
       end if
    end if
next i

Ah… Thanks Dave. I will try this.