Results 1 to 3 of 3

Thread: [RESOLVED] listbox delete item

  1. #1

    Thread Starter
    Lively Member achor's Avatar
    Join Date
    May 2006
    Location
    Porto
    Posts
    123

    Resolved [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:
    1. Private Sub lst1_KeyPress(KeyAscii As Integer)
    2.     If lst1.ListCount > 0 Then
    3.         If KeyAscii = 8 Then
    4.             lst1.RemoveItem lst1.ListIndex
    5.         End If
    6.     End If
    7. 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

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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

  3. #3

    Thread Starter
    Lively Member achor's Avatar
    Join Date
    May 2006
    Location
    Porto
    Posts
    123

    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
  •  



Click Here to Expand Forum to Full Width