how to keypress?

izzyq8

Member
Joined
Dec 29, 2007
Messages
21
Programming Experience
Beginner
i need my program when a button is pushed(v for example) a msgbox appears

i tried keypress but no luck

any help?
 
You have to set KeyPreview property to True for the keyboard events of form to trigger.
 
VB.NET:
Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
        If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.V) Then
            MsgBox("woot")

        End If

    End Sub

tried this but when i push the letter v still no luck
i set the key preview to true in the properties of the form
 
Perhaps try this:
VB.NET:
Private Sub Form1_KeyUp(...) Handles Me.KeyUp
  If e.KeyCode = Keys.V Then MessageBox.Show("woot")
End Sub
 
Back
Top