• Welcome to Valhalla Legends Archive.
 

Finding In a ListBox

Started by TriCk, May 31, 2003, 12:30 AM

Previous topic - Next topic

TriCk

How do u find a username in a listbox?

Noodlez

you loop through every item in the listbox and compare the value of the current item with the username you want to find

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.


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


^-----silly Brit
-----------------------------
www.brimd.com

TriCk

ok ill try that...
Is found supposed to be a string, integer or something?

Zakath

Looks like it's supposed to be a boolean: it's assigned the values "true" and "false."
Quote from: iago on February 02, 2005, 03:07 PM
Yes, you can't have everybody...contributing to the main source repository.  That would be stupid and create chaos.

Opensource projects...would be dumb.

Eternal

Yes, it is a Boolean. I didn't put the declares in...
^-----silly Brit
-----------------------------
www.brimd.com

drivehappy

#6

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

I believe it should actually be that since the list starts at 0.

Eternal

Actually, you are right.  :)
^-----silly Brit
-----------------------------
www.brimd.com

TriCk

Thanx, I'll give it a go...:)