Results 1 to 5 of 5

Thread: Array of unrelated objects

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    ma,usa
    Posts
    485

    Post

    Hi,
    I've got a bunch of textboxes and commandbuttons and it seems to me that there should be a way to iterate through them to change their backcolor.I want them to all keep their existing names and indexs though.
    Anyway to do this?
    Thanks
    joey o.

  2. #2
    Addicted Member
    Join Date
    Jan 2000
    Location
    Oshkosh, WI
    Posts
    163

    Post

    You could loop through the controls collection and then depending on the type of control you could then change the backcolor property or whatever other property you wanted to change.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    ma,usa
    Posts
    485

    Post

    I want to know how to use the controls collection but only choose some of the textboxes.Can I define them as a collection somehow?

  4. #4
    Lively Member
    Join Date
    Jan 2000
    Posts
    76

    Post

    Try this
    for i = 0 to form.controls
    if typeof form.controls(i) is Text then
    ' do whatever
    esle if typeof form.control(i) is Commandbutton then

    ' do whatever

    endif

    next i

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

    Post

    let me pretty up (and correct) svskumar's example
    Code:
    Dim intControl As Integer
    
    For intControl = 0 To Me.Controls.Count - 1
        If TypeOf Me.Controls(intControl) Is TextBox Then
            MsgBox "textbox"
        ElseIf TypeOf Me.Controls(intControl) Is CommandButton Then
        ' do whatever
        
        End If
    Next intControl

    ------------------
    Marty
    What did the fish say when it hit the concrete wall?
    > > > > > "Dam!"

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