>I'm writing a builder which replaces controls. It finds objects of certain class, adds a different object of the new class, copies properties from the old one, RemoveObject()s the old one.
>The trouble is how to do this in a loop. If I try going for i=1 to oParent.ControlCount, as soon as I remove the old one, the whole collection is reshuffled. I'll probably fix it by doing for i=oParent.controlcount to 1 step -1, so those I replaced will be removed from the current position and new ones added in the end, which would be just OK (except the instantiation order would now be reverse - but this should not be important, or there's something wrong with the design).
>
>The trouble I have is when I attempt to do For Each oMember of loObj.Controls - it gives me syntax error for a form with just two objects (a pageframe and a custom). The collection is visible in debugger while the builder runs, and also in the command window - any member of the collection can be accessed by number. It's just that For Each it gives a syntax error.
>
>VFP7 SP1. Can anyone check whether this works in VFP8?
>
>
>aselobj(oForms,1)
>oForm=oForms[1]
>for each oControl of oForm.controls
> ? oControl.name
>endfor
>Save this in a prg and run it while editing a form, I need to know whether anything changed here in VFP8.
Hi Dragan,
I wrote a tool for this purpose which is available in the downloads as NewClass. Check it out.
Glenn