Author | Message | Time |
---|---|---|
Forged | I keep getting the error next without for when this code runs and I have no clue why. I do have a for loop [code] Private Sub CSB_ServerInfo(ByVal Message As String, SimulatedEvent As Boolean) If LCase(Message) = LCase("Your friends are:") Then ' End If For i = 1 To 25 Step 1 If Left((LCase(Message)), 3) = (LCase(i & ": ")) Then ParseFriends Message Next i Else AddC vbYellow, Message End If End Sub [/code] | September 9, 2005, 7:07 PM |
kamakazie | [code] Private Sub CSB_ServerInfo(ByVal Message As String, SimulatedEvent As Boolean) If LCase(Message) = LCase("Your friends are:") Then ' End If For i = 1 To 25 Step 1 If Left((LCase(Message)), 3) = (LCase(i & ": ")) Then ParseFriends Message Next i Else AddC vbYellow, Message End If End Sub [/code] Tabbing reveals the problem... | September 9, 2005, 7:11 PM |
Forged | except that will add the server info 25 times and I don't want to do that. | September 9, 2005, 7:30 PM |
shout | [quote author=Forged link=topic=12753.msg127539#msg127539 date=1126294233] except that will add the server info 25 times and I don't want to do that. [/quote] If you did not notice is the exact same code except it has tabbing. | September 9, 2005, 7:32 PM |
KkBlazekK | [quote author=Forged link=topic=12753.msg127539#msg127539 date=1126294233] except that will add the server info 25 times and I don't want to do that. [/quote] Think then... [code] Private Sub CSB_ServerInfo(ByVal Message As String, SimulatedEvent As Boolean) If LCase(Message) = LCase("Your friends are:") Then ' End If If Left((LCase(Message)), 3) = (LCase(i & ": ")) Then For i = 1 To 25 Step 1 ParseFriends Message Next i Else AddC vbYellow, Message End If End Sub [/code] | September 9, 2005, 8:12 PM |
Forged | For i = 1 to 25 needs to be above the if statement because I am using the value of i in the if statement. | September 9, 2005, 8:17 PM |
KkBlazekK | Hmm, how about we do this the easy way then.. [code] Private Sub CSB_ServerInfo(ByVal Message As String, SimulatedEvent As Boolean) If LCase(Message) = LCase("Your friends are:") Then ' End If For i = 1 To 25 Step 1 If Left((LCase(Message)), 3) = (LCase(i & ": ")) Then ParseFriends Message Else AddC vbYellow, Message Exit For End If Next i End Sub [/code] | September 9, 2005, 8:22 PM |
kamakazie | [quote author=Forged link=topic=12753.msg127553#msg127553 date=1126297042] For i = 1 to 25 needs to be above the if statement because I am using the value of i in the if statement. [/quote] I'm guessing you want to do something like this: [code] Private Sub CSB_ServerInfo(ByVal Message As String, SimulatedEvent As Boolean) If LCase(Message) = LCase("Your friends are:") Then ' Why not lower-case the string yourself? *Lazy* ' End If If Left(Message, 3) Like "#: " Then ParseFriends Message Else AddC vbYellow, Message End If End Sub [/code] Edit: This might only work for 1 digit. Making it work for 2 digits is trivial. | September 9, 2005, 8:24 PM |
Forged | Thank you sir, that is exactlly what I needed. I had never heard of the Like operator before, kind of nifty. | September 11, 2005, 5:33 AM |
JoeTheOdd | In my bot, just print server info to the screen, and update my friends list using 0x.. whatever the packet was. That way if they use /f l it will display correctly. | September 18, 2005, 12:11 AM |
LoRd | [quote author=Forged link=topic=12753.msg127533#msg127533 date=1126292857] I keep getting the error next without for when this code runs and I have no clue why. I do have a for loop [code] Private Sub CSB_ServerInfo(ByVal Message As String, SimulatedEvent As Boolean) If LCase(Message) = LCase("Your friends are:") Then ' End If For i = 1 To 25 Step 1 If Left((LCase(Message)), 3) = (LCase(i & ": ")) Then ParseFriends Message Next i Else AddC vbYellow, Message End If End Sub [/code] [/quote] You're missing an End If. [code] Private Sub CSB_ServerInfo(ByVal Message As String, SimulatedEvent As Boolean) If LCase(Message) = LCase("Your friends are:") Then ' End If For i = 1 To 25 Step 1 If Left((LCase(Message)), 3) = (LCase(i & ": ")) Then ParseFriends Message End If Next i Else AddC vbYellow, Message End If End Sub [/code] | September 18, 2005, 1:28 AM |
JoeTheOdd | [code]If LCase(Message) = LCase("Your friends are:") Then ' End If[/code] I'd comment out the If and End If lines as well (for efficency) or just plain remove them, seeing as how its a compare to do even though it doesn't effect anything. | September 23, 2005, 1:36 AM |