A1VBCode Forums

How to go one TextField to next TextField using Enter Key


http://www.a1vbcode.com/vbforums/Topic31587.aspx

By maheshcse09 - 8/14/2012

hi,

i'm Mahesh,i'm new in VB.i've one dought.How to go one TextField to next TextField using Enter Key.

pls if any one know the concept.pls tell me.



thank u



mahesh
By Mark - 8/16/2012

KeyPreview and SendKeys is what you need.

Private Sub Form_KeyPress(KeyAscii As Integer)
    ' Test for the enter key being pressed
    If KeyAscii = 13 Then
        ' cancel the keypress
        KeyAscii = 0
        ' call the tab key
        SendKeys "{TAB}"
    End If
End Sub

Private Sub Form_Load()
    ' let the form capture keyboard events
    Me.KeyPreview = True
End Sub