Results 1 to 10 of 10

Thread: [RESOLVED] Passing multiple controls to a function

Threaded View

  1. #6
    Hyperactive Member
    Join Date
    Sep 2004
    Posts
    482

    Re: Passing multiple controls to a function

    Quote Originally Posted by riechan View Post
    Thank you for the help. I tried your suggested code and sadly it only reiterated the Tab control. I made a couple more searches using the list method you mentioned and found a set of code here which accomplishes what I needed.

    Unfortunately, I'm not too familiar with using lists. Can you help explain the code to me so I can get a better understanding of it? The gist, if I'm not mistaken, is that the GetChildren() sub gets all of the controls in the active form and lists them down, checks if it has child controls and calls the same sub from within the sub (this is what recursive means, yes?) until such time that the parent control no longer has any child controls?

    Also, what's the significance of the _ in _list? Is this a naming convention pertaining to something?
    Glad you found something that worked for you.

    Think of a List is just a special type of single dimensional array that has methods to add items, remove items etc. and it will automatically adjust it's size as needed. There is also the Dictionary object which is like a List but supports name/value pairs and finally there is a Collection which is similar to a Dictionary and there are advantages and disadvantages to each. That can be some light research for you.

    Yes that is what recursive means.

    Some people use _ as the first character of variable name to make variables easier to spot when reading the code and to avoid a conflict with a reserved word or method. You don't have to use it as long as you make sure your variables don't have any conflicts. For instance you cannot have a variable named "Integer" because Integer already has meaning to VB. You can however, use _Integer if you wanted. I have also seen people indicate variables by using "v" or "var" to start variable names.

    I have never gotten into that habit with variables but I do with Controls. I usually name my controls with a 3 char prefix to designate the type of control and then a Descriptive name. For example txtEmail would indicate a TextBox to collect Email Address and cmbState would be a ComboBox to select State and btnSubmit is a button to Submit the form and so forth. This makes it easier when reading my code to understand what each object is
    Last edited by Maverickz; Mar 20th, 2016 at 11:14 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width