|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Removing the beepfrom, Access has a BeforeUpdate or AfterUpdate event that fires if one hits the tab or Enter key. So I wondered how one fires an event when one hits the Enter key. It appears I have to check for the key press. I entered the following code for a textbox and it beeps at me. Private Sub TextBox1_KeyDown(ByVal sender As Object, _ ByVal e As System.Windows.Forms.KeyEventArgs) _ Handles TextBox1.KeyDown If e.KeyCode = 13 Then Call GoToLink() End If End Sub It doesn't matter if I comment out 'Call GoToLink() I still get a beep. From my testing, it appears the beep is produed when the code hits the End Sub. How can I remove the Beep? Also, is there a better way to validate my textbox when I hit the enter key?
Show quote
Hide quote
"Salad" <sa***@oilandvinegar.com> wrote in message Take a look at the KeyEventArgs object and see if it has a Handled property. news:sdmdnYZVJJ35y1rWnZ2dnUVZ_tmdnZ2d@earthlink.com... > I'm coming from a background with Access. If I have a textbox on a from, > Access has a BeforeUpdate or AfterUpdate event that fires if one hits the > tab or Enter key. > > So I wondered how one fires an event when one hits the Enter key. It > appears I have to check for the key press. I entered the following code > for a textbox and it beeps at me. > Private Sub TextBox1_KeyDown(ByVal sender As Object, _ > ByVal e As System.Windows.Forms.KeyEventArgs) _ > Handles TextBox1.KeyDown > If e.KeyCode = 13 Then > Call GoToLink() > End If > End Sub > > It doesn't matter if I comment out > 'Call GoToLink() > I still get a beep. From my testing, it appears the beep is produed when > the code hits the End Sub. > > How can I remove the Beep? > > Also, is there a better way to validate my textbox when I hit the enter > key? If so, set it to True at the end of the event handler and it'll probably suppress the beep. It used to work this way in VB6 anyway. Tom Dacon Dacon Software Consulting Am 15.04.2010 20:09, schrieb Salad:
Show quoteHide quote > I'm coming from a background with Access. If I have a textbox on a It appears whenever a char is entered that is not accepted by the textbox.> from, Access has a BeforeUpdate or AfterUpdate event that fires if one > hits the tab or Enter key. > > So I wondered how one fires an event when one hits the Enter key. It > appears I have to check for the key press. I entered the following code > for a textbox and it beeps at me. > Private Sub TextBox1_KeyDown(ByVal sender As Object, _ > ByVal e As System.Windows.Forms.KeyEventArgs) _ > Handles TextBox1.KeyDown > If e.KeyCode = 13 Then > Call GoToLink() > End If > End Sub > > It doesn't matter if I comment out > 'Call GoToLink() > I still get a beep. From my testing, it appears the beep is produed > when the code hits the End Sub. This means you could also press Ctrl+A (Chr(1)), etc to produce it. > How can I remove the Beep? Private Sub TextBox1_KeyPress( _ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) _ Handles TextBox1.KeyPress If e.KeyChar = ControlChars.Cr Then e.Handled = True End If End Sub > Also, is there a better way to validate my textbox when I hit the enter key? I don't know.-- Armin Armin Zingler wrote:
Show quoteHide quote > Am 15.04.2010 20:09, schrieb Salad: Thanks for your reply.> >>How can I remove the Beep? > > > Private Sub TextBox1_KeyPress( _ > ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) _ > Handles TextBox1.KeyPress > > If e.KeyChar = ControlChars.Cr Then > e.Handled = True > End If > End Sub > I created a new project/form. Added 2 textboxes. No code. If I enter data into 1 textbox and hit the tab key it silently moves to the next box. If I forego the enter key it beeps at me and sits in the same field. I added your code to Textbox1 (there's no keyChar) so I used If e.KeyCode = Keys.Enter Then e.Handled = True End If instead. It still beeps. I'm wondering if there's a global form setting to turning Beeps off. Or a way to hit an enter key on a field and not have it beep at the user. Also, hit the enter key and move to the next input field like days of old. I have this crazy image of people using vb.net apps worldwide and the beep sound fills the air like flocks of birds. Attack of the Annoying Beeps! Maybe the beeps are used as negative reinforcement to train people to use the Tab key to move to another field instead of the Enter key. Am 16.04.2010 02:12, schrieb Salad:
> It still beeps. Look at my code. It handles the Keypress event, not the Keydown event.-- Armin Armin Zingler wrote:
> Am 16.04.2010 02:12, schrieb Salad: Thanks. Works like a champ when using the right event.> >>It still beeps. > > > Look at my code. It handles the Keypress event, not the Keydown event. > > Hallo Armin,
I think I've not seen this one for 5 years, it was the one which you've always (endless) answered :-) CorShow quoteHide quote "Armin Zingler" <az.nospam@freenet.de> wrote in message news:e4v9ioM3KHA.4028@TK2MSFTNGP05.phx.gbl... > Am 15.04.2010 20:09, schrieb Salad: >> I'm coming from a background with Access. If I have a textbox on a >> from, Access has a BeforeUpdate or AfterUpdate event that fires if one >> hits the tab or Enter key. >> >> So I wondered how one fires an event when one hits the Enter key. It >> appears I have to check for the key press. I entered the following code >> for a textbox and it beeps at me. >> Private Sub TextBox1_KeyDown(ByVal sender As Object, _ >> ByVal e As System.Windows.Forms.KeyEventArgs) _ >> Handles TextBox1.KeyDown >> If e.KeyCode = 13 Then >> Call GoToLink() >> End If >> End Sub >> >> It doesn't matter if I comment out >> 'Call GoToLink() >> I still get a beep. From my testing, it appears the beep is produed >> when the code hits the End Sub. > > It appears whenever a char is entered that is not accepted by the textbox. > This means you could also press Ctrl+A (Chr(1)), etc to produce it. > >> How can I remove the Beep? > > Private Sub TextBox1_KeyPress( _ > ByVal sender As Object, ByVal e As > System.Windows.Forms.KeyPressEventArgs) _ > Handles TextBox1.KeyPress > > If e.KeyChar = ControlChars.Cr Then > e.Handled = True > End If > End Sub > >> Also, is there a better way to validate my textbox when I hit the enter >> key? > > I don't know. > > > -- > Armin > Am 16.04.2010 12:13, schrieb Cor Ligthert[MVP]:
> I think I've not seen this one for 5 years, it was the one which you've I don't remember. Maybe because it's so lang ago. :)> always (endless) answered > > :-) -- Armin Cor Ligthert[MVP] wrote:
> Hallo Armin, It's kindof a shame in a way.> > I think I've not seen this one for 5 years, it was the one which you've > always (endless) answered > > :-) > > Cor There was an MS-app that had no FileOpen dialog. So of course the question as asked, thousands of times, how to show a file/open dialog to the user. Thousands of developers spent time searching for an answer before asking somebody more knowledgeable. Then those knowledgeable spent the time posting the code or a link with the answer. Web pages were created to answer the question. And then the users spent the time getting the code into their application. Most likely man-years were spent, cumulatively, on just this one question. MS could have created that feature for the application and reduced frustration and wasted man hours. It took about 10 years. For the beep question...or even moving to the next field after hitting the enter key...a simple property could have been created, IMO, to move to the next field or turn beep off. Or make their documentation easier to find such answers. Instead, groups like these get to answer the same question over and over. I am glad there are professionals that take the time to answer newbie questions. It is what makes, IMO, Usenet so great. Users helping users. I think MS, and other companies, could review usenet threads every so often, see what areas of their documentation could be improved, and then incorporate their findings in their new releases. If I looked around and saw the same question being asked over and over again I'd know that providing a solution in the help file would help everyone. If obvious to me, it should be obvious to companies. In the meantime while we wait for that which will not happen, the heroes are those the help others. But that's JMO. Show quoteHide quote > > "Armin Zingler" <az.nospam@freenet.de> wrote in message > news:e4v9ioM3KHA.4028@TK2MSFTNGP05.phx.gbl... > >> Am 15.04.2010 20:09, schrieb Salad: >> >>> I'm coming from a background with Access. If I have a textbox on a >>> from, Access has a BeforeUpdate or AfterUpdate event that fires if one >>> hits the tab or Enter key. >>> >>> So I wondered how one fires an event when one hits the Enter key. It >>> appears I have to check for the key press. I entered the following code >>> for a textbox and it beeps at me. >>> Private Sub TextBox1_KeyDown(ByVal sender As Object, _ >>> ByVal e As System.Windows.Forms.KeyEventArgs) _ >>> Handles TextBox1.KeyDown >>> If e.KeyCode = 13 Then >>> Call GoToLink() >>> End If >>> End Sub >>> >>> It doesn't matter if I comment out >>> 'Call GoToLink() >>> I still get a beep. From my testing, it appears the beep is produed >>> when the code hits the End Sub. >> >> >> It appears whenever a char is entered that is not accepted by the >> textbox. >> This means you could also press Ctrl+A (Chr(1)), etc to produce it. >> >>> How can I remove the Beep? >> >> >> Private Sub TextBox1_KeyPress( _ >> ByVal sender As Object, ByVal e As >> System.Windows.Forms.KeyPressEventArgs) _ >> Handles TextBox1.KeyPress >> >> If e.KeyChar = ControlChars.Cr Then >> e.Handled = True >> End If >> End Sub >> >>> Also, is there a better way to validate my textbox when I hit the >>> enter key? >> >> >> I don't know. >> >> >> -- >> Armin >> Salad,
Nothing wrong with your question, I found it only strange that for 5 years ago this was an often asked question. And then suddenly it stopped and now that question comes again. Just strange in my idea, but whatever, doesn't bother me. Cor Show quoteHide quote "Salad" <sa***@oilandvinegar.com> wrote in message news:_Pqdna1qOI1ANFXWnZ2dnUVZ_g2dnZ2d@earthlink.com... > Cor Ligthert[MVP] wrote: > >> Hallo Armin, >> >> I think I've not seen this one for 5 years, it was the one which you've >> always (endless) answered >> >> :-) >> >> Cor > > It's kindof a shame in a way. > > There was an MS-app that had no FileOpen dialog. So of course the > question as asked, thousands of times, how to show a file/open dialog to > the user. Thousands of developers spent time searching for an answer > before asking somebody more knowledgeable. Then those knowledgeable spent > the time posting the code or a link with the answer. Web pages were > created to answer the question. And then the users spent the time getting > the code into their application. Most likely man-years were spent, > cumulatively, on just this one question. > > MS could have created that feature for the application and reduced > frustration and wasted man hours. It took about 10 years. > > For the beep question...or even moving to the next field after hitting the > enter key...a simple property could have been created, IMO, to move to the > next field or turn beep off. Or make their documentation easier to find > such answers. > > Instead, groups like these get to answer the same question over and over. > I am glad there are professionals that take the time to answer newbie > questions. It is what makes, IMO, Usenet so great. Users helping users. > > I think MS, and other companies, could review usenet threads every so > often, see what areas of their documentation could be improved, and then > incorporate their findings in their new releases. If I looked around and > saw the same question being asked over and over again I'd know that > providing a solution in the help file would help everyone. If obvious to > me, it should be obvious to companies. > > In the meantime while we wait for that which will not happen, the heroes > are those the help others. But that's JMO. > >> >> "Armin Zingler" <az.nospam@freenet.de> wrote in message >> news:e4v9ioM3KHA.4028@TK2MSFTNGP05.phx.gbl... >> >>> Am 15.04.2010 20:09, schrieb Salad: >>> >>>> I'm coming from a background with Access. If I have a textbox on a >>>> from, Access has a BeforeUpdate or AfterUpdate event that fires if one >>>> hits the tab or Enter key. >>>> >>>> So I wondered how one fires an event when one hits the Enter key. It >>>> appears I have to check for the key press. I entered the following >>>> code >>>> for a textbox and it beeps at me. >>>> Private Sub TextBox1_KeyDown(ByVal sender As Object, _ >>>> ByVal e As System.Windows.Forms.KeyEventArgs) _ >>>> Handles TextBox1.KeyDown >>>> If e.KeyCode = 13 Then >>>> Call GoToLink() >>>> End If >>>> End Sub >>>> >>>> It doesn't matter if I comment out >>>> 'Call GoToLink() >>>> I still get a beep. From my testing, it appears the beep is produed >>>> when the code hits the End Sub. >>> >>> >>> It appears whenever a char is entered that is not accepted by the >>> textbox. >>> This means you could also press Ctrl+A (Chr(1)), etc to produce it. >>> >>>> How can I remove the Beep? >>> >>> >>> Private Sub TextBox1_KeyPress( _ >>> ByVal sender As Object, ByVal e As >>> System.Windows.Forms.KeyPressEventArgs) _ >>> Handles TextBox1.KeyPress >>> >>> If e.KeyChar = ControlChars.Cr Then >>> e.Handled = True >>> End If >>> End Sub >>> >>>> Also, is there a better way to validate my textbox when I hit the enter >>>> key? >>> >>> >>> I don't know. >>> >>> >>> -- >>> Armin >>> >
Button calling aother button's code
How to set the Tab size in a TextBox Control Bug outside IDE only in Release mode DateGridView NRE Error how to capture a photo from my web cam ? communication between two vb apps Refer to childs of user control. Re: JPG Processing in .NET Help for populate Chart How to show scroll bars only if actually required |
|||||||||||||||||||||||