Traversing a form/frame's controls through code
-
I have recently begun working in a job with VB6. I am used to embedded C/C++, so there is a large learning curve for me. What I am trying to do is make a class or module that can traverse all the controls on a form. I want a generic way to choose any given control within my code. I looked at the form methods, but cannont find anything that will return a collection of controls. The "Form.Controls" property looked promising, but would not return a collection of controls. It returns an object representing the controls. Is there any way to use this, or anything else in VB6 that would allow my to select controls within my code without knowing how many controls are on the form? Perhaps there is something visible through the tab order? Thanks in advance, Paul
-
I have recently begun working in a job with VB6. I am used to embedded C/C++, so there is a large learning curve for me. What I am trying to do is make a class or module that can traverse all the controls on a form. I want a generic way to choose any given control within my code. I looked at the form methods, but cannont find anything that will return a collection of controls. The "Form.Controls" property looked promising, but would not return a collection of controls. It returns an object representing the controls. Is there any way to use this, or anything else in VB6 that would allow my to select controls within my code without knowing how many controls are on the form? Perhaps there is something visible through the tab order? Thanks in advance, Paul
THe
.Controls
collection is what your looking for. It returns the collection of contorls on the form. What's the problem your having? What do you mean by "select"? What exactly are you trying to do? RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome -
THe
.Controls
collection is what your looking for. It returns the collection of contorls on the form. What's the problem your having? What do you mean by "select"? What exactly are you trying to do? RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming GnomeI have actually managed to figure out exactly what I needed to do. I used the .Controls collection, but took it farther. I looped on the total number of controls to look at .Controls.Item(index). This allowed me to browse through every control on the form. I needed to do this because I was generically assigning data to them. Thank you for your inteset in helping :-) On another note, I was concerned by the fact that the .Controls property returns an Object, not a Collection. How can I assign an object to anything? Can this only be done with a variant data type?