Ok, I'm writing a program that consists of a listbox and adding strings to it. At some point I want to be able to delete one of those items and highlight the item that falls in its place. Here's the actual coding I've been using:
Private Sub delCmd_Click()
Dim count
Dim c As Integer
c = -1 '*Finding the actual length of 'the list that's not null*
Do '*Finding the number of items in the list that are not null*
c = c + 1
Loop Until List1.List(c) = ""
If List1.Text = "" Then
MsgBox "Nothing selected or list is empty!"
Else
For count = 0 To c - 1
List1.RemoveItem count
If List1.List(count) > "" Then
List1.Selected(count) = True
End If
Next count
End If
End Sub
This compiles just fine, but when working with the running program, I get a Run time error 5 where there's an invalid call procedure or argument and the line "List1.RemoveItem count" is highlighted. Can anyone help me with that? If it matters, I'm working on WinXP.
Private Sub delCmd_Click()
Dim count
Dim c As Integer
c = -1 '*Finding the actual length of 'the list that's not null*
Do '*Finding the number of items in the list that are not null*
c = c + 1
Loop Until List1.List(c) = ""
If List1.Text = "" Then
MsgBox "Nothing selected or list is empty!"
Else
For count = 0 To c - 1
List1.RemoveItem count
If List1.List(count) > "" Then
List1.Selected(count) = True
End If
Next count
End If
End Sub
This compiles just fine, but when working with the running program, I get a Run time error 5 where there's an invalid call procedure or argument and the line "List1.RemoveItem count" is highlighted. Can anyone help me with that? If it matters, I'm working on WinXP.