Results 1 to 6 of 6

Thread: (Resolved) Removing Items from listbox

  1. #1

    Thread Starter
    Addicted Member Illiad's Avatar
    Join Date
    Mar 2003
    Location
    Chicago
    Posts
    196

    (Resolved) Removing Items from listbox

    I have a string called "Alias". Basically when a user quits the program I need lstUsers list to remove the value of "Alias" from the list. How do I do that???
    Last edited by Illiad; Mar 26th, 2003 at 07:14 PM.
    Quis Custodiet Ipsos Custodes?

    You don't have to be faster than the bear, you just have to be faster than the slowest person running from the bear.

  2. #2
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    VB Code:
    1. Dim indx As Long
    2.  
    3. 'If you wan't to remove [b]all[/b] instances of "Alias"
    4. For indx = List1.ListCount - 1 To 0 Step -1
    5.     If List1.List(indx) = "Alias" Then List1.RemoveItem indx
    6. Next
    7.  
    8.  
    9. 'Or
    10.  
    11. 'If you wan't to remove [b]one[/b] instance of "Alias"
    12. Dim indx As Long
    13.  
    14. For indx = List1.ListCount - 1 To 0 Step -1
    15.     If List1.List(indx) = "Alias" Then
    16.         List1.RemoveItem indx
    17.         Exit For
    18.     End If
    19. Next
    Last edited by Bruce Fox; Mar 26th, 2003 at 06:30 PM.

  3. #3
    Fanatic Member
    Join Date
    Oct 1999
    Location
    England
    Posts
    982
    You may have to watch your CAPS in comparing strings. I have had trouble in the past where "Alias" is not the same as "alias".

    If you know uppercase/lowercase the text is in then you are OK otherwise use the Ucase() function to change both strings to the same case.

  4. #4

    Thread Starter
    Addicted Member Illiad's Avatar
    Join Date
    Mar 2003
    Location
    Chicago
    Posts
    196
    I said I made a varaible called Alias. Alias is the var! its contents are what im removing, not the word Var....just cauz im a Junior Member dosnt mean i dont know some programming stuff....
    Quis Custodiet Ipsos Custodes?

    You don't have to be faster than the bear, you just have to be faster than the slowest person running from the bear.

  5. #5
    Fanatic Member
    Join Date
    Oct 1999
    Location
    England
    Posts
    982
    OK I guess we both misread your post. Use Bruce Fox's code but put your variable at the correct place and be careful of upper and lowercase characters.

    I remember being junior once.

  6. #6

    Thread Starter
    Addicted Member Illiad's Avatar
    Join Date
    Mar 2003
    Location
    Chicago
    Posts
    196
    Yea I'm getting there....

    Thanks for the heads up anyways i found the " around the word Alias in Brute's code and deleted them. The code works wonderfully now!
    Quis Custodiet Ipsos Custodes?

    You don't have to be faster than the bear, you just have to be faster than the slowest person running from the bear.

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