Help?
Private Sub CleanSlateBot1_UserLeaves(ByVal Username As String, ByVal Flags As Long, SimulatedEvent As Boolean)
Username = Replace(Username, "*", "")
On Error Resume Next
For i = 1 To ListView1.ListItems.Count
If ListView1.ListItems(i) = Username Then
ListView1.ListItems.Remove i
End If
Next i
AddChat rtbChat, Username & " has left the channel.1", vbGreen, vbNewLine
End Sub
Dosen't Generate an error nut it instead add another user with the same name instead of deleting it.
Nvm i think i fixed this
Taken from ETH bot
Private Sub Event_Leave(strUser As String, StrFlag)
On Error Resume Next
Dim strCount As String
strCount = frmMain.RoomList.ListItems.count
If Err.Number = 0 Then
frmMain.RoomList.ListItems.Remove frmMain.RoomList.FindItem(strUser).Index
End If
addText strUser & " has left the channel" & vbNewLine, ID_COLOR_INFO
frmMain.text1.text = msChannelName & " (" & frmMain.RoomList.ListItems.count & ")"
End Sub
Quote from: AC_Drkan on July 12, 2004, 03:57 PM
Nvm i think i fixed this
Taken from ETH bot
Private Sub Event_Leave(strUser As String, StrFlag)
On Error Resume Next
Dim strCount As String
strCount = frmMain.RoomList.ListItems.count
If Err.Number = 0 Then
frmMain.RoomList.ListItems.Remove frmMain.RoomList.FindItem(strUser).Index
End If
addText strUser & " has left the channel" & vbNewLine, ID_COLOR_INFO
frmMain.text1.text = msChannelName & " (" & frmMain.RoomList.ListItems.count & ")"
End Sub
nvm the nvm im lost
look >>here (http://forum.valhallalegends.com/phpbbs/index.php?board=31;action=display;threadid=7743)<<
Well you could use a loop like this.
Private Sub CleanSlateBot1_UserLeaves(ByVal Username As String, ByVal Flags As Long, SimulatedEvent As Boolean)
Username = Replace(Username, "*", "")
For i = 1 To ListView1.ListItems.Count
If LCase(ListView1.ListItems(i)) = LCase(Username) Then
ListView1.ListItems.Remove(i)
GoTo ShowMessage
End If
Next i
ShowMessage: 'Jump to this to save time from checking the other users.
AddChat rtbChat, Username & " has left the channel.1", vbGreen, vbNewLine
End Sub
Also your On Error Resume Next might be jumping through an error you are receiving, try removing that and debugging the error.
One other thing, is it adding the users with a * on the listview? Because if it is, your loop won't find a match.
If it's truly a listview, and not a listbox, you should be able to just simply do:
listview1.ListItems.Remove listview1.FindItem(Username).index
Quote from: Eli_1 on August 08, 2004, 08:26 PM
If it's truly a listview, and not a listbox, you should be able to just simply do:
listview1.ListItems.Remove listview1.FindItem(Username).index
Took the words right out of my mouth!
Quote from: BaDDBLooD on August 08, 2004, 10:52 PM
Quote from: Eli_1 on August 08, 2004, 08:26 PM
If it's truly a listview, and not a listbox, you should be able to just simply do:
listview1.ListItems.Remove listview1.FindItem(Username).index
Took the words right out of my mouth!
Don't make useless replies - if someone has already given the answer and it's not being disputed by someone else, there's no need to tell everyone that you agree about the answer. If we all did, these topics would all be a dozen pages long in no time, and we don't want that.
Quote from: Eli_1 on August 08, 2004, 08:26 PM
If it's truly a listview, and not a listbox, you should be able to just simply do:
listview1.ListItems.Remove listview1.FindItem(Username).index
Remember to handle the VB error that will occur if FindItem does not find the name in the ListView and you pass that Index (of a Null object) to the Remove method of ListItems. In this particular application you are never expecting it, since you will only be removing from the ListView those items which you have added, but half the point of error handlers is for the unexpected, keeping your program from crashing ungracefully.
ThY ALL!!!!
fixed the removing and adding, look:
Private Sub CleanSlateBot1_UserLeaves(ByVal Username As String, ByVal Flags As Long, SimulatedEvent As Boolean)
Username = Replace(Username, "*", "")
'Code For Removing a User From a List View Goes Here
Username = Replace(Username, "*", vbNullString)
On Error Resume Next
lvChannel.ListItems.Remove lvChannel.FindItem(Username).Index
lblChannel.Caption = Channel & " (" & lvChannel.ListItems.Count & ")"
If mnuToggleJLMessages.Checked = True Then
AddChat rtbChat, Username & " has left the channel.", vbGreen, vbNewLine
End If
End Sub
Might want to do
lvChannel.ListItems.Refresh
after the removal because sometimes things look a little tacky and bits and pieces of icons get stuck, also I notice you are using CSB, and I recommend you actually use my BNLS Logon Control (http://turbonet.feeblegaming.org/blc/), because it can logon W3 and has a few extra features, check it out :)
Quote from: ChR0NiC on August 20, 2004, 12:44 PM
Might want to do
lvChannel.ListItems.Refresh
after the removal because sometimes things look a little tacky and bits and pieces of icons get stuck, also I notice you are using CSB, and I recommend you actually use my BNLS Logon Control (http://turbonet.feeblegaming.org/blc/), because it can logon W3 and has a few extra features, check it out :)
IIRC, CSB can log on W3 just fine.
By the way Drkan, On Error Resume Next is a very poor way of "handling" errors.
Quote from: Eli_1 on August 20, 2004, 01:33 PM
IIRC, CSB can log on W3 just fine.
It doesn't work correctly anymore, it gets a run time error subscript out of range error when logging on W3, which means it needs to be updated. So you are incorrect Eli >:(
Quote from: Eli_1 on August 20, 2004, 01:33 PM
Quote from: ChR0NiC on August 20, 2004, 12:44 PM
Might want to do
lvChannel.ListItems.Refresh
after the removal because sometimes things look a little tacky and bits and pieces of icons get stuck, also I notice you are using CSB, and I recommend you actually use my BNLS Logon Control (http://turbonet.feeblegaming.org/blc/), because it can logon W3 and has a few extra features, check it out :)
:'(
i know but thats so much easier
IIRC, CSB can log on W3 just fine.
By the way Drkan, On Error Resume Next is a very poor way of "handling" errors.