Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Traversing a form/frame's controls through code

Traversing a form/frame's controls through code

Scheduled Pinned Locked Moved Visual Basic
c++hardwarequestioncareer
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Pualee
    wrote on last edited by
    #1

    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

    D 1 Reply Last reply
    0
    • P Pualee

      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

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      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

      P 1 Reply Last reply
      0
      • D Dave Kreskowiak

        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

        P Offline
        P Offline
        Pualee
        wrote on last edited by
        #3

        I 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?

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups