Results 1 to 2 of 2

Thread: Problem with control collections

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 1999
    Location
    chennai,tamilnadu,india
    Posts
    29

    Post

    Hi,

    When we loop through controls collection
    (For ...each)is it possible to loop through the ctrls in same order as taborder if yes how .Because in my case looping is starting from some random point.

    Thanx
    Murali

  2. #2
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Mobile, AL, USA
    Posts
    600

    Post

    Hi Murali.

    Here's a way to loop through the controls in Tab Order.

    For each control on your Form, set the Tag property to the same value of the Taborder. Place a command button on the Form and put this code in the VB Editor:
    Code:
    Option Explicit
    
    Private Sub Command1_Click()
        Dim iCounter As Integer
        
        For iCounter = Form1.Controls.Count - 1 To 0 Step -1
                MsgBox "Control: " & Form1.Controls(iCounter).Name & vbCrLf & _
                       "Tag: " & Form1.Controls(iCounter).Tag
        Next
    End Sub
    All the best.

    ------------------
    OneSource
    The truth may be out there, but it's in here too!
    .

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