Getting ubound of control index

I have created 7 buttons on my web app page and given them all the name “btn” and created a control set so they are listed 0 to 6. I plan to add more buttons at a later date but I want to add some dynamic code before they are displayed so I need to do two things but I cant get them to work:

  1. I tried using btn.ubound (as it came up in the intelitype) but is says thats not allowed so how do you find out the index of the last button in the control set?

  2. As I loop through to access the buttons properties how can I in code know if the button still exists, for example lets say I delete button with index of 3 so my loop that goes from 0 to 6 will give an error when it reaches the deleted one and I try to access the property of it?

you can keep a property of your own.

Or you loop up until you find one which is nil.

Track these in an array of your own. The ubound thing has not worked consistently with design/docs for about forever.

Ok, thanks.

[quote=101862:@Nathan Wright]I have created 7 buttons on my web app page and given them all the name “btn” and created a control set so they are listed 0 to 6. I plan to add more buttons at a later date but I want to add some dynamic code before they are displayed so I need to do two things but I cant get them to work:
[/quote]
Note that “control sets” do NOT have to have contiguous indexes so yours could be 1, 10, 20, 30, 40, 50 ,60 with lots of gaps

[quote=101862:@Nathan Wright]1) I tried using btn.ubound (as it came up in the intelitype) but is says thats not allowed so how do you find out the index of the last button in the control set?
[/quote]
you go through the controls on the page & see which ones have that name & track the highest index you find

Since there can be gaps you have a hard time knowing
I never use control sets and favor container controls instead