Results 1 to 5 of 5

Thread: listbox.additem troubles?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2000
    Posts
    70
    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()

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    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.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Apr 2000
    Posts
    70
    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()

  4. #4
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    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

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Apr 2000
    Posts
    70
    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
  •  



Click Here to Expand Forum to Full Width