Sign in to follow this  

VB.NET - keyboard input

This topic is 4687 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
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

This topic is 4687 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this