G
Guest
Hello. I have managed to consume the key 9 when it is pressed,
by using the following code:
Private Sub RichTextBox1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles RichTextBox1.KeyPress
'If key 9 on keyboard is pressed show this in a messagebox
'and then consume the stroke using e.handled=true
If e.KeyChar = ChrW(57) Then
MessageBox.Show("hello", "57", MessageBoxButtons.OK,
MessageBoxIcon.Information)
e.Handled = True
End If
End Sub
However the above code will not consume the use of the "Backspace" key. That
code looks like the following:
Private Sub RichTextBox1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles RichTextBox1.KeyPress
'If Backspace key on keyboard is pressed show this in a messagebox
'and then consume the stroke using e.handled=true
If e.KeyChar = ChrW(8) Then
MessageBox.Show("hello", "8 Backspace", MessageBoxButtons.OK,
MessageBoxIcon.Information)
e.Handled = True
End If
End Sub
Anyone happen to know why??????
Thank you,
Brenton Garman
by using the following code:
Private Sub RichTextBox1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles RichTextBox1.KeyPress
'If key 9 on keyboard is pressed show this in a messagebox
'and then consume the stroke using e.handled=true
If e.KeyChar = ChrW(57) Then
MessageBox.Show("hello", "57", MessageBoxButtons.OK,
MessageBoxIcon.Information)
e.Handled = True
End If
End Sub
However the above code will not consume the use of the "Backspace" key. That
code looks like the following:
Private Sub RichTextBox1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles RichTextBox1.KeyPress
'If Backspace key on keyboard is pressed show this in a messagebox
'and then consume the stroke using e.handled=true
If e.KeyChar = ChrW(8) Then
MessageBox.Show("hello", "8 Backspace", MessageBoxButtons.OK,
MessageBoxIcon.Information)
e.Handled = True
End If
End Sub
Anyone happen to know why??????
Thank you,
Brenton Garman