From: Salad on
Armin Zingler wrote:
> Am 16.04.2010 02:12, schrieb Salad:
>
>>It still beeps.
>
>
> Look at my code. It handles the Keypress event, not the Keydown event.
>
>
Thanks. Works like a champ when using the right event.
From: Cor Ligthert[MVP] on
Hallo Armin,

I think I've not seen this one for 5 years, it was the one which you've
always (endless) answered

:-)

Cor

"Armin Zingler" <az.nospam(a)freenet.de> wrote in message
news:e4v9ioM3KHA.4028(a)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
>
From: Armin Zingler on
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
> always (endless) answered
>
> :-)

I don't remember. Maybe because it's so lang ago. :)



--
Armin
From: Salad on
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(a)freenet.de> wrote in message
> news:e4v9ioM3KHA.4028(a)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
>>
From: Cor Ligthert[MVP] on
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


"Salad" <salad(a)oilandvinegar.com> wrote in message
news:_Pqdna1qOI1ANFXWnZ2dnUVZ_g2dnZ2d(a)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(a)freenet.de> wrote in message
>> news:e4v9ioM3KHA.4028(a)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
>>>
>