-
Hi
this is the code I hoped would remove
blanck list items.
VB doesn't like the line
List1.RemoveItem x
but I can't see anything wrong
with it
The code.
Private Sub Command5_Click()
For x = 0 To List1.ListCount
If List1.List(x) = "" Then
List1.RemoveItem x
End If
Next x
List1.Refresh
End Sub
Thanks for your time
Chris Davidsen
-
A tip for Chris Davidson
Hmm...simple problem, simple answer.
Here's a solution:
Code:
Private Sub Command1_Click()
Dim x As Long, c As Boolean
Do Until x = List1.ListCount - 1
c = False
If List1.List(x) = "" Then
List1.RemoveItem x
c = True
End If
If c = False Then x = x + 1
Loop
List1.Refresh
End Sub
Your code:
Code:
For x = 0 To List1.ListCount - 1
If List1.List(x) = "" Then
List1.RemoveItem x
'Whenever you remove an item, the LISTCOUNT changes, but VB would still
'try to get x to the OLD Listcount, so using Do Until solves the problem!
'You can also use Do While.
End If
Next x
List1.Refresh
Satisfactory? :rolleyes::rolleyes::rolleyes::rolleyes:
-
Thanks man :-)
-
No problem. Glad to help:).