• Welcome to Valhalla Legends Archive.
 

How do i load from a listbox

Started by TriCk, May 23, 2003, 07:20 AM

Previous topic - Next topic

TriCk

how do i choose items from a listbox ?
say like an access thing... ?

drivehappy

QuotePrivate Sub List1_Click()
MsgBox List1.List(List1.ListIndex)
End Sub

TriCk

hmmm
I tried that with cleanslatebot ...
Code:
CleanSlateBot_UserJoins
If Username = List.List(List.ListIndex) Then
'Don't Ban
Else If Username = Username Then
CleanSlateBot.Send "/ban " & username


Doesnt work...
how would i get it to work with that sort of setup i have there ?

drivehappy

CleanSlateBot_UserJoins
If trim(ucase(Username)) = trim(ucase(List.List(List.ListIndex))) Then
'Don't Ban
Else
CleanSlateBot.Send "/ban " & Username
End If

Try that.

TriCk

hmmm thats still not working
I have my name on the list but if i join it still bans me...
are u sure that code is right ?

Camel

that code compares the name of the user joining to the value of the selected item in the list. you probably want to search through the list and compare the users name to every entry, rather than just the selected one.

TriCk

yeah how would i do that?
code please
i'm sorta newb to vb6   :(

TriCk

how do i find a username in a listbox so they dont get banned when they join ?

drivehappy

CleanSlateBot_UserJoins()
For X = 0 to List1.Listcount -1
  If trim(ucase(Username)) = trim(ucase(List1.List(X)) Then
    'Don't Ban
  ElseIf Trim(UCase(Username)) <> List1.List(X) and X = (List1.Listcount - 1) Then
    CleanSlateBot.Send "/ban " & Username
  End If
Next

TriCk


TriCk

hmmm...
one more thing... it only works for 1 person if i put more than 1 person in the listbox it bans the first one whys it doin that ??

Mesiah / haiseM

]HighBrow Innovations
Coming soon...

AIM Online Status: 

Camel

Quote from: TriCk on May 24, 2003, 02:36 AM
how do i find a username in a listbox so they dont get banned when they join ?

Quote from: Camel on May 23, 2003, 08:30 PM
...search through the list and compare the users name to every entry...
or use the [listbox].FindItem method as mesiah pointed out

TriCk

are u talking about VB .net ? Coz i dont think on VB6 they have ListBox.FindItem ...?

I also own VB .net but im using vb6 for this bot

drivehappy

#14
Trick, it depends on what you have Username set to when you loop it. I'm trying to figure out what you're not doing right, so this is my best guess:

CleanSlateBot_UserJoins()
Dim Username() as String
For Y = 0 to UBound.Username
 For X = 0 to List1.Listcount -1
   If trim(ucase(Username(Y))) = trim(ucase(List1.List(X)) Then
     'Don't Ban
     Exit For
   ElseIf Trim(UCase(Username(Y))) <> List1.List(X) and X = (List1.Listcount - 1 Then
     CleanSlateBot.Send "/ban " & Username(Y)
     Exit For
   End If
 Next
Next


Kind of messy, but it should work. The Username array should contain all the usernames you don't want banned.

Edit: use [ code ] tags.