Results 1 to 3 of 3

Thread: Control Collection

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 1999
    Location
    Bangalore,Karnataka,india
    Posts
    8

    Post

    Hi!
    I have a collection of controls that i build in the form load.
    How do i access each control in it.
    The code is like this...

    For Each mycontrol in controls
    if typeof mycontrol is textbox then
    mycollection.add mycontrol
    next

    Now in mycollection i want to access a control.

    Thanks in advance...
    satheesg

  2. #2
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    266

    Post

    How about this ?

    for i=0 to mycollection.controls.count-1
    mycollection.control(i).propertyname = propertyvalue
    next i


  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    msdnexpert may be thinking of something else, but a collection has only 4 properties: Add, Count, Item, and Remove. To access a control you use the Item property and do something like this
    Code:
    For i = 1 To mycollection.Count
    mycollection.Item(i).BackColor = 1234
    Next i
    Note that while most VB things are 0-based a collection is 1-based.

    ------------------
    Marty

    [This message has been edited by MartinLiss (edited 11-30-1999).]

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