Referencing a Controls Siblings

When a VB form has multiple container controls, it is sometimes useful to quickly reference only the other controls in that container (what I call "siblings"). For example, clicking a checkbox control in a frame control may need to cause the other controls in the frame to become locked, while leaving the other controls on the form alone. This function returns a collection of all such "sibling" controls (based on the control that is passed in). You can then iterate over the returned collection of controls using For Each...Next. (Note that the function itself iterates over all the form's controls to determine which ones to include, so it's not a time-saver as much as a code-saver.)

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish