954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

KeyPress Enter to Tab Muli-TextBox Form

Hi. This may seem simple to most but has consumed 3 days so far and a bit of $$ trying to learn simple how to use Enter as a Tab (Yes I know it is a Fau-par but I need it regardless).

The idea is to move the focus to the next TextBox (don't worry about the Case 38, 58 etc too much I).

I have 6 large books on VB.NET 2003 and have been googling for days with no joy.

Please help. Thank you.

My Code:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'(Unrelated code here)

AddHandler Form1.KeyDown, AddressOf EnterkeyHandler 'Would like to understand this better
End Sub

Private Sub EnterkeyHandler(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)
        If e.KeyCode = Keys.Enter Then MsgBox("Enter Working")
        TextBox = TextBox + 1
        If TextBox = 18 Or TextBox = 38 Or TextBox = 58 Or TextBox = 78 Then
            Select Case TextBox
                Case 18
                    TextBox = 21
                Case 38
                    TextBox = 41
                Case 58
                    TextBox = 61
                Case 78
                    TextBox = 1
            End Select
        End If
        If Forward = True Then
            Call FwdFieldEntries()
        Else
            Call RevFieldEntries()
        End If
        e.Handled = True 'Must be within A Handle Event to avoid "not handling the event, you are simply overriding it"
    End Sub
    Private Sub FwdFieldEntries()

        Select Case TextBox
            Case 1
                tbxTestNº1.Focus()
            Case 2
                tbxSampleNº1.Focus()
            Case 3
                tbxFinMassBotS.Focus()
BasicDinosaur
Newbie Poster
2 posts since Sep 2007
Reputation Points: 10
Solved Threads: 0
 

On form Properties enable KeyPreview. Set it to True.

It's a little puzzling that you joined in 2007 but this your first post.

Please introduce yourself :) http://www.daniweb.com/forums/forum165.html

finito
Nearly a Posting Virtuoso
1,321 posts since May 2010
Reputation Points: 60
Solved Threads: 135
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: