Results 1 to 2 of 2

Thread: Tab key action

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2000
    Location
    U.S.A.
    Posts
    50
    On a form in my project I have about 20 or so text boxes that I use to display data. As we all know when you press the "TAB" key it advances the focus to the next control based on it's TabIndex value. My problem is that when I press the "SHIFT TAB" key conbination the focus may go back to the previous control the first or second time, but rarely works correctly again if I press "SHIFT TAB" again. What I'm looking for a way to assign focus to a control by using it's TabIndex value.

    For example: Form1.SetFocus = 3

    This action would set focus on the control that has been assigned a TabIndex value of 3. This example doesn't work (of course) but I am looking for something similar.

    Thanks in advance.

  2. #2
    Guest
    You can use a For...Each loop to check the TabIndex of each control then set the focus if it's 3.
    Code:
    Dim ctl As Control
    
    For Each ctl In Controls
        If ctl.TabIndex = 3 Then ctl.SetFocus
    Next ctl

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