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!

Delete Key Intercept 1

Status
Not open for further replies.

borgunit

Programmer
Mar 25, 2002
373
US
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?

Thanks
 
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 Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
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 Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Thanks,
That was it. I was using KeyPress instead of KeyDown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top