-
Ok.. Here's the deal. I've got a listbox with ALOT of names in it. I can check them one by one, and delete them one by one by pressing the Cmdbutton that are linked to that function, but I'd like to be able to use a button on the tgb insted, lika "delete" (which is the most logical button for this operation.. ;)
How do I do this??
I'd also like to be able to check more then one name at the time, and delete them all at once. help plz...
Thanks in advance!
-
hmmm... what's a tgb?
and ehrm.. here's code to delete multiple selections
Code:
For x = 0 To List1.Listcount - 1
If List1.Selected(x) Then List1.RemoveItem x
Next x
-
Tgb = Tangenbord = keyboard..
Sorry.. Couldn't remember the english transaltion at the time, så I wrote tgb and hoped that people would understand it anyway.
Thanks for the help with the delete-problem.
-
oh, for the tangenbord I have this solution...
Code:
'Set the forms KeyPreview to True
Private Sub Form_KeyDown(KeyCode As Integer)
If KeyCode = vbKeyDelete Then
'call the sub from here
End If
End Sub
-
Or try this (I had problems going from 0 to List1.ListCount -1 while deleting multiple selection so I did it in reverse)
Code:
'//Set Form's KeyPreview property to True
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim I As Integer
If KeyCode = vbKeyDelete Then
For I = List1.ListCount - 1 To 0 Step -1
If List1.Selected(I) Then
List1.RemoveItem (I)
End If
Next I
End If
End Sub
-
Yep, that's even better mate!!! because you won't get any probs with 'missing' listitems :) cool!
-
Thanks for the help! U rock!