Identify Control Index exists?

Can anyone tell me how to identify whether a Control Set Control’s Index exists. Due to numbering issues I’ve encountered after closing WebImageView controls and then creating a new set I want to just re purpose existing WebImageView controls but I have to identify that a particular index exists so I don’t create new controls unnecessarily.

You can get the indices currently available like this

[code] dim indices() As integer

for i As integer = 0 to self.ControlCount - 1 //loop over all controls
if Control(i).Name = “nameOfControlSet” then //if name matches
indices.Append Control(i).Index //store the index
end
next

indices.Sort //optional clean up[/code]

Then you can check the array for gaps or the ending value. But I’m not sure it matters as far as memory is concerned. I mean if you have 2 controls in the set with Index 0 and the other with Index 9999 I don’t think there’s an internal array with empty indices 1 to 9998. I think it’s just a set of 2 items and the items Index can be anything (except duplicated amongst the set).

the way i have done it previously its create a property as boolean
when the index is closed then make the value false and when its in use make true
then when you look or loop though you know what ones are in use or not

Thanks guys. This is awesome info. I ending up realizing in my case all I really needed to know is if a WebImageView control of a specific index had been created. If It had it was already in use. If not the Control would be Nil so If ImageViewThumb(i) = Nil Then ImgBox = AddImageViewThumb worked fine for my purposes this time since I realized I did not need to close any existing controls. I’m just hiding them off of the active ContainerControl if unused and changing their picture property and unhiding when the number of pictures needed increases. If one doesn’t exist I create one and it takes the next available index.