|
-
Jan 3rd, 2007, 06:01 AM
#1
Thread Starter
Lively Member
[RESOLVED] listbox delete item
Hello all,
I have a list box and I want to delete an item by pressing 'delete'
My code only works with backspace... What can I do?
VB Code:
Private Sub lst1_KeyPress(KeyAscii As Integer)
If lst1.ListCount > 0 Then
If KeyAscii = 8 Then
lst1.RemoveItem lst1.ListIndex
End If
End If
End Sub
I supose that ascii code for delete key is 127... but if you press 'delete', the event lst1_KeyPress don't catch it...
Thanks
-
Jan 3rd, 2007, 06:15 AM
#2
Re: listbox delete item
delete key does not show as a keypress, try in the keydown event with keycode 46
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jan 3rd, 2007, 06:29 AM
#3
Thread Starter
Lively Member
Re: listbox delete item
Fantastic, it works!
Thanks!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|