+ Reply to Thread
Results 1 to 2 of 2

Tab between Textboxes

  1. #1
    Registered User
    Join Date
    03-22-2005
    Posts
    31

    Tab between Textboxes

    Hi everyone. I'm having trouble tabbing between textboxes. I have this code which works fine, but want to also include if you press shift+tab to go backwards to the previous text box.
    Is this possible?
    Also, is it possible to make it so you tab from text boxes to buttons with hyperlinks attached??
    Thanks

    Below is the code I used

    Private Sub TextBox1_KeyDown(ByVal KeyCode As _
    MSForms.ReturnInteger, ByVal Shift As Integer)
    If KeyCode = vbKeyTab = 1 Then TextBox2.Activate
    End Sub

    This is the shift+tab bit but don't know how to include it.
    If KeyCode = vbKeyTab And Shift = 1 Then TextBox4.Activate

    Thanks

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Carlito_1985,

    You need to test if the Shift Key was pressed. Here is how...

    Private Sub TextBox1_KeyDown(ByVal KeyCode As _
    MSForms.ReturnInteger, ByVal Shift As Integer)
    Select Case Shift
    Case Is = 0 'Move Tab Forward
    If KeyCode = vbKeyTab Then TextBox2.Activate
    Case Is = 1 "Move Tab Backward - Shift Key Pressed
    If KeyCode = vbKeyTab Then TextBox1.Activate
    End Select
    End Sub

    Shift Values:
    1 = Shift Key
    2 = Ctrl Key
    4 = Alt Key


    These values can be added to form combinations of these keys.

    Hope this answers your questions,
    Leith Ross

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1