0

My form's KeyPreview is set to True. I want to allow my users to use the Enter Key instead of just the Tab key. I have the following code in my form's KeyPress event:

Private Sub frmDesigner_KeyPress(ByVal sender As Object, ByVal e As   System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
        If e.KeyChar = vbkeyreturn Then
            SendKeys.Send("{TAB}")
        End If
    End Sub

It doesn't like vbkeyreturn, which I used in Visual Basic 6.0. I think I must be close to having it right. Your help is appreciated!

~ Sheryl

3
Contributors
3
Replies
13
Views
8 Years
Discussion Span
Last Post by hlove4u
0

Hi,

Private Sub frmDesigner_KeyPress(ByVal sender As Object, ByVal e As   System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
        If Asc(e.KeyChar) = Keys.Enter Then
            SendKeys.Send("{TAB}")
        End If
End Sub

Edited by mike_2000_17: Fixed formatting

0

My form's KeyPreview is set to True. I want to allow my users to use the Enter Key instead of just the Tab key. I have the following code in my form's KeyPress event:

Private Sub frmDesigner_KeyPress(ByVal sender As Object, ByVal e As   System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
        If e.KeyChar = vbkeyreturn Then
            SendKeys.Send("{TAB}")
        End If
    End Sub

It doesn't like vbkeyreturn, which I used in Visual Basic 6.0. I think I must be close to having it right. Your help is appreciated!

~ Sheryl

just declare your vbkeyreturn, that does it

Dim vbkeyreturn as char=chr(13)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.