Detecting when Delete key is pressed
Ok, I have set my form's key preview value to true and have modified the Form_KeyPress event sub, however I can't get it to find when the user presses the Delete key. All normal letters and numbers seem to get detected, but the delete key isn't for some reason.
Here's a little test Sub I wrote it just checks if the user hits delete and if something is selected in a list box it will delete that item:
Private Sub Form_KeyPress(KeyAscii As Integer)
Dim i As Integer
MsgBox ("YOU HAVE PRESSED " & Chr(KeyAscii))
If KeyAscii = 46 Then
For i = main_list.ListCount - 1 To 0 Step -1
If main_list.Selected(i) Then
main_list.RemoveItem (i)
End If
Next i
End If
End Sub
Any help would be greatly appreciated. Thanks in advance.
Re: Detecting when Delete key is pressed
Put it under:
private Sub Form_KeyDown(KeyCode as Integer, Shift as Integer)
If KeyCode = 46 then
MsgBox "Delete was pressed", , App.Title
End If
End Sub
--
Chizl
[email protected]
http://www.chizl.com/