|
-
Oct 19th, 2000, 04:33 AM
#1
Thread Starter
Lively Member
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?
Daniel Rose
VB 5.0 Enterprise.
irc:irc2.dynam.ac
If TheCodeInTheSig() Is Not Lame() Then IDontKnowWhatIs()
-
Oct 19th, 2000, 04:44 AM
#2
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.
-
Oct 20th, 2000, 04:35 AM
#3
Thread Starter
Lively Member
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.
Daniel Rose
VB 5.0 Enterprise.
irc:irc2.dynam.ac
If TheCodeInTheSig() Is Not Lame() Then IDontKnowWhatIs()
-
Oct 20th, 2000, 05:01 AM
#4
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
-
Oct 20th, 2000, 05:22 AM
#5
Thread Starter
Lively Member
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..
Daniel Rose
VB 5.0 Enterprise.
irc:irc2.dynam.ac
If TheCodeInTheSig() Is Not Lame() Then IDontKnowWhatIs()
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|