Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How do I get rid of the beep when you press Enter?

Posted on 2007-11-30
9
Medium Priority
?
500 Views
Last Modified: 2008-02-01
I want to use the Enter key like a Tab key.  I have code to do that, but it still beeps every time you press Enter.  How do I get rid of that? In VB 2005
Private Sub TxtSeasonal_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TxtSeasonal.KeyDown
        If e.KeyCode = 13 Then
            SendKeys.Send("{tab}")
        End If
    End Sub

Open in new window

0
Comment
Question by:Jimmy Lea
  • 4
  • 4
9 Comments
 
LVL 19

Expert Comment

by:darron_chapman
ID: 20387060
Try this....
Private Sub TxtSeasonal_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TxtSeasonal.KeyDown
        If e.KeyCode = 13 Then
            SendKeys.Send("{tab}")
            e.KeyCode = 0
        End If
    End Sub

Open in new window

0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 20387301
darron...that looks like a VB6 approach forced into .Net syntax...

VB6 would look like:

    Private Sub TxtSeasonal_KeyPress(KeyAscii As Integer)
        KeyAscii = 0
        SendKeys "{Tab}"
    End Sub

In VB.Net, though, it would be:

    Private Sub TxtSeasonal_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TxtSeasonal.KeyPress
        If e.KeyChar = Microsoft.VisualBasic.ChrW(13) Then
            e.Handled = True
            SendKeys.Send("{tab}")
        End If
    End Sub
0
 

Author Comment

by:Jimmy Lea
ID: 20390384
Thanks for the reply guys.

Darron,
e.KeyCode = 0
gives err saying it is read only
'Property KeyCode is Read Only'

Bob,
e.Handled = True in the KeyDown
nothing changed
I also tried it as a KeyPress event and e.Handle = True
When I did that it would not except the text.  But it didn't beep.

Is there something I'm doing wrong?
Any other thoughts?

Thanks
Jim



0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:Jimmy Lea
ID: 20390387
Sorry Idle_Mind don't know where I got Bob from.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 20391428
It worked fine for me in the KeyPress() event...

Show us what code you are CURRENTLY using.
0
 

Author Comment

by:Jimmy Lea
ID: 20393670
The code snipplet in the original post is what I am Currently using.  What are you asking for?  
This is a data entry app that takes numbers, I wanted the users to be able use the number pad.  So I would like them to be able to use the Enter key to go between txt boxes.  Is there a property in the txt box that makes the keypress event work?  I'm fairly green at programming so it may be something simple.  Do you want the code for the whole form?

Thanks for your reply
Jim
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 20393688
It should work with just the KeyPress() event:

    Private Sub TxtSeasonal_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TxtSeasonal.KeyPress
        If e.KeyChar = Microsoft.VisualBasic.ChrW(13) Then
            e.Handled = True
            SendKeys.Send("{tab}")
        End If
    End Sub

GET RID OF THE KEYDOWN() CODE YOU ALREADY HAVE...
0
 

Author Comment

by:Jimmy Lea
ID: 20393715
Ok, when I tried the the Keypress event I still had the Keydown in there.  I'm sure that was it. I will replace it Monday and give it a go.  I figured it was something silly.  Thanks for your help.

Jim
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 20393737
No problem.  Let us know if it still doesn't work as expected...we'll figure it out!  ;)
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question