Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to detect delete keypress in a form control

Status
Not open for further replies.

bkowlagi

Programmer
Apr 8, 2003
28
US
I have this datagrid on a form. now if the user clicks on the leftmost column of the row and presses the Delete button the row gets deleted. I want to trap the delete key and set keyascii = 0. but there is no ascii code for delete key. How do i do it?

P.S. I have the same problem in VB.NET as well.

Probably there is a common solution to detct delte key for any control.
 
Have you tried the constant
Code:
'vbKeyDelete'
.

Code:
If KeyAscii = vbKeyDelete then KeyAscii = 0

Take Care,

zemp

"If the grass looks greener... it's probably because there is more manure."
 
Sorry, the constant is a keycode constant. You can use it in the Keydown or Keyup event.

Code:
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
   If KeyCode = vbKeyDelete Then MsgBox "Delete key."
End Sub

Take Care,

zemp

"If the grass looks greener... it's probably because there is more manure."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top