Results 1 to 3 of 3

Thread: Reference a control by name...[RESOLVED]

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2001
    Location
    Buffalo, NY
    Posts
    297

    Reference a control by name...[RESOLVED]

    Hey everyone,

    I feel like an idiot asking this but...

    I have a collection of controls that I add to my form programmatically, and was wondering how I can refer to specific controls by name? I'd rather not loop through the controls collection and compare names, since there could be many of these controls.

    Thanks,

    Ben
    Last edited by BenFinkel; Dec 22nd, 2003 at 12:11 PM.

  2. #2
    Junior Member
    Join Date
    Dec 2003
    Posts
    16
    Try putting them in a HashTable:

    Dim oControl As New Hashtable()

    ' Add controls
    oControl.Add("name1", TextBox1)
    oControl.Add("name2", TextBox2)
    oControl.Add("name3", TextBox3)

    dim t as textbox

    t = oControl("name1)

    Fred

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2001
    Location
    Buffalo, NY
    Posts
    297
    Thanks Fred, worked perfectly!

    --Ben

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