Author | Message | Time |
---|---|---|
AC_Drkan | Help? [code] 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 [/code] Dosen't Generate an error nut it instead add another user with the same name instead of deleting it. | July 12, 2004, 8:39 PM |
AC_Drkan | Nvm i think i fixed this [code] 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 [/code] | July 12, 2004, 8:57 PM |
AC_Drkan | [quote author=AC_Drkan link=board=31;threadid=7681;start=0#msg70019 date=1089665864] Nvm i think i fixed this [code] 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 [/code] [/quote] nvm the nvm im lost | August 3, 2004, 4:02 AM |
dRAgoN | look >>here<< | August 3, 2004, 12:36 PM |
ChR0NiC | Well you could use a loop like this. [code] 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 [/code] 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. | August 6, 2004, 7:39 PM |
Eli_1 | If it's truly a listview, and not a listbox, you should be able to just simply do: [code] listview1.ListItems.Remove listview1.FindItem(Username).index [/code] | August 9, 2004, 1:26 AM |
BaDDBLooD | [quote author=Eli_1 link=board=31;threadid=7681;start=0#msg74651 date=1092014806] If it's truly a listview, and not a listbox, you should be able to just simply do: [code] listview1.ListItems.Remove listview1.FindItem(Username).index [/code] [/quote] Took the words right out of my mouth! | August 9, 2004, 3:52 AM |
Adron | [quote author=BaDDBLooD link=board=31;threadid=7681;start=0#msg74669 date=1092023555] [quote author=Eli_1 link=board=31;threadid=7681;start=0#msg74651 date=1092014806] If it's truly a listview, and not a listbox, you should be able to just simply do: [code] listview1.ListItems.Remove listview1.FindItem(Username).index [/code] [/quote] Took the words right out of my mouth! [/quote] 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. | August 9, 2004, 10:14 AM |
Grok | [quote author=Eli_1 link=board=31;threadid=7681;start=0#msg74651 date=1092014806] If it's truly a listview, and not a listbox, you should be able to just simply do: [code] listview1.ListItems.Remove listview1.FindItem(Username).index [/code] [/quote] 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. | August 9, 2004, 11:27 AM |
AC_Drkan | ThY ALL!!!! fixed the removing and adding, look: [code] 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 [/code] | August 20, 2004, 2:45 AM |
ChR0NiC | Might want to do [code]lvChannel.ListItems.Refresh[/code] 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, because it can logon W3 and has a few extra features, check it out :) | August 20, 2004, 5:44 PM |
Eli_1 | [quote author=ChR0NiC link=board=31;threadid=7681;start=0#msg76418 date=1093023846] Might want to do [code]lvChannel.ListItems.Refresh[/code] 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, because it can logon W3 and has a few extra features, check it out :) [/quote] IIRC, CSB can log on W3 just fine. By the way Drkan, On Error Resume Next is a very poor way of "handling" errors. | August 20, 2004, 6:33 PM |
ChR0NiC | [quote author=Eli_1 link=board=31;threadid=7681;start=0#msg76424 date=1093026810] IIRC, CSB can log on W3 just fine. [/quote] 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 >:( | August 20, 2004, 9:12 PM |
AC_Drkan | [quote author=Eli_1 link=board=31;threadid=7681;start=0#msg76424 date=1093026810] [quote author=ChR0NiC link=board=31;threadid=7681;start=0#msg76418 date=1093023846] Might want to do [code]lvChannel.ListItems.Refresh[/code] 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, because it can logon W3 and has a few extra features, check it out :) [/quote] :'( 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. [/quote] | September 17, 2004, 10:26 AM |