-
Hey guys, i'm having a little trouble with a listbox and the additem method..
I add my first item, with the index of 0, increment the index i use then add the next etc, i remove the entry in the listbox with .removeitem <index> method and it removes fine, *but* as soon as i try to re add that same item (the same string), with a different index, it errors with invalid procedure call or argument... any ideas?
-
First of all: If you want to add a new string at the end of the list you don't have to pass the index.
When you remove a string from the list all strings that are after that one in the list gets a new index. If you increment your "index counter" when you add a string you must decrement it when you remove a string.
-
if i dont specify an index, i cant remove the entry, as to remove it you need to know it, and without specifying it i have no way to find it.
-
This depends on when your removing it. Does the user select one item to be removed?
As I understand your question you actually want to move one string in the listbox. But where are you moving it? To the end of the list or to an other position?
Here's an example that moves a string to the bottom of the list:
Code:
'move the SELECTED string to the bottom of List1
Dim sText As String
sText = List1.Text
List1.RemoveItem List1.ListIndex
List1.AddItem sText
Best regards
-
Hi,
i actually want to remove a value from the box which may or may not be selected, i remove it depending on data i recieve from the server via tcp/ip connections.. i dont care where in the list they are (though an alphabetical sort would be nice) and i dont want to move them once in the list.. i just need to remove them, then re-add as the server requires..