Hi,
I am trying to delete entries in a ListBox by using the delete key. I can react to the DEL key (KeyAscii 46) but the Delete Key (one of those MS ergo keyboards doesn't seem to send a KeyAscii code when pressed). Any suggestions?
Use the KeyDown Event of the List Box.
This worked for me.
Private Sub List1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyDelete Then
With List1
If .ListIndex >= 0 Then
.RemoveItem (.ListIndex)
End If
End With
End If
End Sub
Oops. Change that.
Private Sub List1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyDelete Then
With List1 If .ListCount > 0 Then
.RemoveItem .ListIndex
End If
End With
End If
End Sub
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.