Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2007-11-30
9
Medium Priority
?
499 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

730 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