Results 1 to 5 of 5

Thread: Yeah, piece of cake... for you!

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2000
    Posts
    18

    Question

    I know it must be the abc of programing but, can somebody
    tell me how can i make, so when i press enter in a
    textbox then other textbox getfocus???

  2. #2
    Fanatic Member Stevie's Avatar
    Join Date
    Mar 2000
    Location
    London, UK
    Posts
    565
    Code:
    Public Sub TextBox1_KeyPress(KeyAscii As Integer)
    
      ' Check if return has been pressed
      If KeyAscii = vbKeyReturn Then TextBox2.SetFocus
    
    End Sub

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jun 2000
    Posts
    18

    Smile Thanks

    Thanks Stevie it worked perfectly!!

  4. #4
    Guest

    Wink Just an a idea.

    What you can do if you got multi textboxes.
    Code:
    Public Sub TextBox_KeyPress(Index As Integer, KeyAscii As Integer)
    
      ' Check if return has been pressed
      If KeyAscii = vbKeyReturn Then TextBox.Item(Index + 1).SetFocus
    
    End Sub
    Just create the indexes on it.
    Code:
    TextBox.Index = 0 'ext, ext.


  5. #5
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    ...or if you don't have the text boxes in an array just change the Return to a Tab
    Code:
    Public Sub TextBox_KeyPress(KeyAscii As Integer)
        If KeyAscii = vbKeyReturn Then
            KeyAscii = 0
            SendKeys "{TAB}"
        End If
    End Sub
    Good luck!

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