• Advertisement
Sign in to follow this  

VB.NET - keyboard input

This topic is 4754 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to manage the input from the keyboard. You know, when I press Down Arrow, message box appears. That is just an example. I managed it to work when you press ENTER. But what is with other keys? This is my code:
 Public Sub bb()
        ' Create a TextBox control.
        Dim tb As New TextBox
        Me.Controls.Add(tb)
        AddHandler tb.KeyPress, AddressOf keypressed
        AddHandler tb.KeyPress, AddressOf keypressed2
    End Sub 'New

    Sub keypressed(ByVal o As [Object], ByVal e As KeyPressEventArgs)
        If e.KeyChar = Microsoft.VisualBasic.ChrW(14) Then
            MsgBox("Pressed!", , "Pressed!")
        End If
    End Sub
Can anyone help me please? Thanks, -rex

Share this post


Link to post
Share on other sites
Advertisement
It only looks like you are testing for character 14, which my guess would be enter. I would suggest diving into MSDN and looking for the keyboard enumerations.

It should look some thing like VBK_SPACE or junk like that.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement