Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: TriCk on May 31, 2003, 12:30 AM

Title: Finding In a ListBox
Post by: TriCk on May 31, 2003, 12:30 AM
How do u find a username in a listbox?
Title: Re:Finding In a ListBox
Post by: Noodlez on May 31, 2003, 01:07 AM
you loop through every item in the listbox and compare the value of the current item with the username you want to find
Title: Re:Finding In a ListBox
Post by: Eternal on May 31, 2003, 01:42 AM
Here's an example which might help. This piece of code searches a listbox for a string (say, a persons username). If it finds it, the loop exits.


For i = 1 To ListBoxName.ListCount
    If StringYouareComparing = ListBoxName.List(i) Then
        found = True
        Exit For
   Else
        found = False
   End If
Next i


Title: Re:Finding In a ListBox
Post by: TriCk on May 31, 2003, 03:54 AM
ok ill try that...
Is found supposed to be a string, integer or something?
Title: Re:Finding In a ListBox
Post by: Zakath on May 31, 2003, 07:32 AM
Looks like it's supposed to be a boolean: it's assigned the values "true" and "false."
Title: Re:Finding In a ListBox
Post by: Eternal on May 31, 2003, 10:10 AM
Yes, it is a Boolean. I didn't put the declares in...
Title: Re:Finding In a ListBox
Post by: drivehappy on May 31, 2003, 10:52 AM

    If StringYouareComparing = ListBoxName.List(i-1) Then

I believe it should actually be that since the list starts at 0.
Title: Re:Finding In a ListBox
Post by: Eternal on May 31, 2003, 12:08 PM
Actually, you are right.  :)
Title: Re:Finding In a ListBox
Post by: TriCk on May 31, 2003, 09:45 PM
Thanx, I'll give it a go...:)