Valhalla Legends Forums Archive | Battle.net Bot Development | Finding In a ListBox

AuthorMessageTime
TriCk
How do u find a username in a listbox?
May 31, 2003, 5:30 AM
Noodlez
you loop through every item in the listbox and compare the value of the current item with the username you want to find
May 31, 2003, 6:07 AM
Eternal
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.

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

May 31, 2003, 6:42 AM
TriCk
ok ill try that...
Is found supposed to be a string, integer or something?
May 31, 2003, 8:54 AM
Zakath
Looks like it's supposed to be a boolean: it's assigned the values "true" and "false."
May 31, 2003, 12:32 PM
Eternal
Yes, it is a Boolean. I didn't put the declares in...
May 31, 2003, 3:10 PM
drivehappy
[code]
If StringYouareComparing = ListBoxName.List(i-1) Then
[/code]
I believe it should actually be that since the list starts at 0.
May 31, 2003, 3:52 PM
Eternal
Actually, you are right. :)
May 31, 2003, 5:08 PM
TriCk
Thanx, I'll give it a go...:)
June 1, 2003, 2:45 AM

Search