Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Determining number of objects in a form
Message
From
22/11/1999 19:15:47
 
 
To
22/11/1999 18:56:17
Jorge Haro
Independent Consultant
Juarez, Mexico
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00294135
Message ID:
00294141
Views:
24
>I'm trying to make a loop to go through all the objects in my form, I've heard this mentioned before, but never seen any actual code.
>
>I'm trying to use the objects collection, in the debugger it says that it's an array, the help file indicates the same but if I use alen(ThisForm.Objects), I get an error saying "Objects is not an array", wrong syntax?.
>
>Anyway I gave that idea up, and tried with amembers, and it kind of worked, with a small problem, amembers counts the dataenvironment as an object, which sounds good to me. But when seen on the debugger the DE is not inside the objects collection, so during the loop I get an error when I get to the last element, the strange thing is that I get "Objects is not an array again", instead of an out of bounds error. There's no problem using ThisForm.Objects[i] to reference individual objects.
>
>For now I'll just substract one from the value returned from amembers, but being such a common process I suppose there's a cleaner way to do it isn't there?, and could anyone explain what's up with the DE not being in the objects collection?

You can use the ControlCount property to get what you want with one caveat: ControlCount doesn't ocunt the controls inside other containers. To get a complete count, you'll have to use a recursive method that can deal with nested containers, and do the count yourself. Check out message #257688 for an example of how to write a routine like this. The example is a RunAll method, but you could easily modify it to just count controls.
Erik Moore
Clientelligence
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform