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

How to use SendKeys?

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

Sheryl99
Light Poster
27 posts since Sep 2008
Reputation Points: 10
Solved Threads: 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

reena12
Light Poster
32 posts since Oct 2008
Reputation Points: 12
Solved Threads: 4
 

Your solution works! Thank you, Reena!
~ Sheryl

Sheryl99
Light Poster
27 posts since Sep 2008
Reputation Points: 10
Solved Threads: 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)

hlove4u
Newbie Poster
3 posts since Dec 2009
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You