943,568 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Marked Solved
  • Views: 17493
  • VB.NET RSS
Nov 16th, 2008
0

How to use SendKeys?

Expand Post »
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:

VB.NET Syntax (Toggle Plain Text)
  1. Private Sub frmDesigner_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
  2. If e.KeyChar = vbkeyreturn Then
  3. SendKeys.Send("{TAB}")
  4. End If
  5. 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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
Sheryl99 is offline Offline
27 posts
since Sep 2008
Nov 17th, 2008
0

Re: How to use SendKeys?

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
Reputation Points: 12
Solved Threads: 4
Light Poster
reena12 is offline Offline
32 posts
since Oct 2008
Nov 17th, 2008
0

Re: How to use SendKeys?

Your solution works! Thank you, Reena!
~ Sheryl
Reputation Points: 10
Solved Threads: 0
Light Poster
Sheryl99 is offline Offline
27 posts
since Sep 2008
Dec 12th, 2009
0

Hi

Click to Expand / Collapse  Quote originally posted by Sheryl99 ...
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:

VB.NET Syntax (Toggle Plain Text)
  1. Private Sub frmDesigner_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
  2. If e.KeyChar = vbkeyreturn Then
  3. SendKeys.Send("{TAB}")
  4. End If
  5. 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)
Reputation Points: 10
Solved Threads: 0
Newbie Poster
hlove4u is offline Offline
3 posts
since Dec 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: vb.net project titles
Next Thread in VB.NET Forum Timeline: Help: Video Playout Code - Reg.





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC