Textbox beeps and it shouldn't 
Author Message
 Textbox beeps and it shouldn't

Hi!

        When the keypress event of a text box fires, I check to see if
the user pressed enter, if he did, I perform something.

        The problem is, the textbox also beeps when I click return,
and I DON'T want it... How can I avoid this stupid behaviour?

      Fernando Rodriguez Romero

      frr at pobox dot com



Mon, 04 Jun 2001 03:00:00 GMT  
 Textbox beeps and it shouldn't
Add to the "Enter key handler" in the KeyPress event:

If KeyAscii = 13 then
    KeyAscii = 0
    ' do the rest of your stuff
end if

John Tegelaar

Quote:

>Hi!

> When the keypress event of a text box fires, I check to see if
>the user pressed enter, if he did, I perform something.

> The problem is, the textbox also beeps when I click return,
>and I DON'T want it... How can I avoid this stupid behaviour?

>      Fernando Rodriguez Romero

>      frr at pobox dot com



Mon, 04 Jun 2001 03:00:00 GMT  
 Textbox beeps and it shouldn't
I am also experiencing the same situation. I convert the enter key to tabs
by using:

If KeyCode = 13 then SendKeys "{TAB}"

The form entry screen works fine. A user enters their info and hits TAB or
RETURN and rolls right on through the program, but everytime they hit
RETURN, I get a 'BEEP'. I have tried setting KeyCode (and KeyAscii) to 0 (or
anything else I can think of). Nothing seems to work. Anyone have any ideas?

TIA
-Doug

Quote:

>Add to the "Enter key handler" in the KeyPress event:

>If KeyAscii = 13 then
>    KeyAscii = 0
>    ' do the rest of your stuff
>end if

>> The problem is, the textbox also beeps when I click return,
>>and I DON'T want it... How can I avoid this stupid behaviour?



Wed, 06 Jun 2001 03:00:00 GMT  
 Textbox beeps and it shouldn't
OK, here is my fix:

Send TAB instead of ENTER on a form:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then SendKeys "{TAB}"
End Sub

(You must also set KeyPreview to TRUE in the forms properties)
Then, under the forms keypress routine:

Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then KeyAscii = 0
End Sub

Now my TAB and ENTER key work like the TAB key and I get no BEEPS!

HTH
-Doug

Quote:

>I am also experiencing the same situation. I convert the enter key to tabs
>by using:



Wed, 06 Jun 2001 03:00:00 GMT  
 Textbox beeps and it shouldn't
You've got your code in the wrong event. You should use the Text Box
KeyPress (NOT the KeyDown event). I would also advise against setting
KeyPreview to True and using the Form's events - because you may later add
another Text Box or other control in which you do NOT want to trap the Enter
Key.

In the KeyPress event of the Text Box use:

If KeyAscii = 13 then
KeyAscii = 0
' etc (use SetFocus or Sendkeys - either is OK)
End If

Mike

Quote:

>I am also experiencing the same situation. I convert the enter key to tabs
>by using:

>If KeyCode = 13 then SendKeys "{TAB}"

>The form entry screen works fine. A user enters their info and hits TAB or
>RETURN and rolls right on through the program, but everytime they hit
>RETURN, I get a 'BEEP'. I have tried setting KeyCode (and KeyAscii) to 0
(or
>anything else I can think of). Nothing seems to work. Anyone have any
ideas?



Thu, 07 Jun 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Avoid beep when TextBox's text length equal MaxLength

2. Beep won't beep

3. Beep Beep Beep

4. This shouldn't work, but ...

5. It just shouldn't be this complicated...

6. Shouldn't this be easy?

7. Forms taking focus when they shouldn't

8. Please Help: Shouldn't this work?

9. Record Locking Shouldn't Be So Hard

10. EZTouchPOS Why you shouldn't buy it

11. It shouldn't have done that...

12. Shouldn't this timer go off?

 

 
Powered by phpBB® Forum Software