KeyDown in VB.Net?

  • Thread starter Thread starter Sven
  • Start date Start date
S

Sven

I only know the keydown-event in VB 6, there it is like this:

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
XXXXXXXXXXX
End If

How can I do this in VB.Net? can I do this overriding other settings?

Thanks a lot!
 
Sven,

The Form class exposes the KeyDown event. You can add a handler for this
event in the Windows Forms designer. The event arguments passed are little
bit more complex than those passed to the VB6 counterpart, please refer to
MSDN for examples and more detailed information.
 
Hi Dimitry,

Are you mixing things up with C# the events in VB.net works almost the same
as in VB6?

Cor
 
Hi EricJ,

Back, I was thinking where is he :-)

Did you see how many Belgen (Vlaams) are active or regulars to this
newsgroup.

Cor
 
* "Sven said:
I only know the keydown-event in VB 6, there it is like this:

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
XXXXXXXXXXX
End If

How can I do this in VB.Net? can I do this overriding other settings?

What's the problem?

\\\
Private Sub Form2_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyUp
If e.KeyCode = Keys.Return Then
Beep()
End If
End Sub
///
 
This is not a C# event, this is the System.Windows.Form's class event which
always works the same way regardless of the programming language.
 
Hi Dmitriy

Yes and it is working in a computer program, but that was not the question.
The question was where you can put the handler, beneath are both your
answers.
This is not a C# event, this is the System.Windows.Form's class event which
always works the same way regardless of the programming language.

Please if you give answers, be sure that they are right. And when you make a
mistake and someone makes you attent on that, just say, "Thank you",
everybody can make mistakes.

Cor
 
Please if you give answers, be sure that they are right. And when you make
a
mistake and someone makes you attent on that, just say, "Thank you",
everybody can make mistakes.

I have just realized where I was wrong. I completely forgot that, in VB
..NET, event handlers are added not the same way they are in C# - in VB .NET,
one should choose the object and its event from comboboxes at the top of the
code editing windows, while in C# one can add an event handler from the
Properties window.

I am really sorry for posting incorrect information, and I really appreciate
that you have pointed out my mistake.
 
:)
changed work, don't have a lot of spare time here and i have been working on
a few access app's lately.

I'm starting a asp.net app soon so i'll probably be here more often :)
 
Back
Top