• Welcome to Valhalla Legends Archive.
 

Code not activating from module.

Started by GoSu_KaOs, January 27, 2005, 08:15 PM

Previous topic - Next topic

GoSu_KaOs

Aight, I got this:



'moduleBnet"
ID_JOIN
frmMain.figureout
****

'frmMain
Sub figureout()
Dim itm1 As ListItem, itm2 As ListItem
Dim str1 As String, str2 As String

For Each itm1 In frmAliasManager.lvAliases.ListItems 'loop the first listview
If InStr(1, itm1.Text, ":") Then 'just make sure ":" is in there
 str1 = Left$(LCase(itm1.Text), InStr(1, LCase(itm1.Text), ":") - 1)  'get the leftside of ":"
 str2 = Mid$(LCase(itm1.Text), InStr(1, LCase(itm1.Text), ":") + 1)  'get the rightside of ":"
 
  For Each itm2 In Form1.ChannelList.ListItems 'loop second listview
   If LCase(itm2.Text) = str1 Then  'see if it matches the string
     itm2.Text = str2 'if it does, change it
   End If
  Next itm2
End If
Next itm1
End Sub


The problem is, When someone joins a channel, eveyrthing under ID_JOIN activates exept frmMain.Figureout. When I put Call frmMain.Figureout ina  button, it works. But in moduleBnet, it doesent activate. This is gettin frustrating.

Help?

Kp

Quote from: GoSu_KaOs on January 27, 2005, 08:15 PMHelp?

Yes: write better code.  I'm pretty sure even VB supports splitting text on a delimiter, so that left/mid construct isn't needed.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

Newby

Quote from: Kp on January 27, 2005, 08:31 PM
Quote from: GoSu_KaOs on January 27, 2005, 08:15 PMHelp?

Yes: write better code.  I'm pretty sure even VB supports splitting text on a delimiter, so that left/mid construct isn't needed.
Split()
- Newby

Quote[17:32:45] * xar sets mode: -oooooooooo algorithm ban chris cipher newby stdio TehUser tnarongi|away vursed warz
[17:32:54] * xar sets mode: +o newby
[17:32:58] <xar> new rule
[17:33:02] <xar> me and newby rule all

Quote<TehUser> Man, I can't get Xorg to work properly.  This sucks.
<torque> you should probably kill yourself
<TehUser> I think I will.  Thanks, torque.

GoSu_KaOs

#3
Quote from: Kp on January 27, 2005, 08:31 PM
Quote from: GoSu_KaOs on January 27, 2005, 08:15 PMHelp?

Yes: write better code.  I'm pretty sure even VB supports splitting text on a delimiter, so that left/mid construct isn't needed.

What does left/mid have to do with ID_JOIN.
It doesnt activate the code. I tryed making it, Sub figureout, module1.figureout, Call figureout, still not activating.

Networks

Quote from: GoSu_KaOs on January 27, 2005, 08:43 PM
Quote from: Kp on January 27, 2005, 08:31 PM
Quote from: GoSu_KaOs on January 27, 2005, 08:15 PMHelp?

Yes: write better code.  I'm pretty sure even VB supports splitting text on a delimiter, so that left/mid construct isn't needed.

What does left/mid have to do with ID_JOIN.
It doesnt activate the code. I tryed making it, Sub figureout, module1.figureout, Call figureout, still not activating.

use debug.print and figure out where the problem lies.

The-FooL

Do you have an Error handler somewhere that may be causing it to stop execution? 

Also, make a breakpoint at the top of ID_Join and step through to find the problem.

GoSu_KaOs

#6
Fixed it! The problem was, I put frmMain.Figureout before the usernames were added to the Listview.

But now, when the userleaves the channel, the renamed username doesent get removed from the listview.

This is my ID_LEAVE code:

Case ID_LEAVE
For X = 1 To Form1.ChannelList.ListItems.Count
  If frmMain.ChannelList.ListItems.Item(X).Text = Username Then
    frmMain.ChannelList.ListItems.Remove (frmMain.ChannelList.FindItem(Username).Index)
End If
Next X


The problem is , this code compares the Username and the text in the listview. If the username is the same as the listview, it removes the text from the listview. But now, since the listview text is renamed, the code doesnt remove it because the Username and the listview text doesnt match up.
Is there a way to fix this?

I was thinking, mabe using the Split meathod I used before, but in reverse. It loads all the usernames that are stored as "username1:alias1", get the text before and after the ":", and use the text before the ":" to find the text after ":" in the listview. Then remove the text.

I cant figure out how to write this.

Adron

Quote from: Kp on January 27, 2005, 08:31 PM
Quote from: GoSu_KaOs on January 27, 2005, 08:15 PMHelp?

Yes: write better code.  I'm pretty sure even VB supports splitting text on a delimiter, so that left/mid construct isn't needed.

VB5 doesn't. Have to use the Left/Mid thing.

iago

Quote from: Adron on January 28, 2005, 03:26 AM
Quote from: Kp on January 27, 2005, 08:31 PM
Quote from: GoSu_KaOs on January 27, 2005, 08:15 PMHelp?

Yes: write better code.  I'm pretty sure even VB supports splitting text on a delimiter, so that left/mid construct isn't needed.

VB5 doesn't. Have to use the Left/Mid thing.

Then the suggestion would be to use a more up-to-date language.  Java 1.3 also doesn't have split(), so I update to Java 1.4 :)
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


GoSu_KaOs

I need this done in a few days, can anyone figure out how to remove the changed username from the listview?

I've been tying but all I get is errors.

drivehappy

#10

Case ID_LEAVE
For X = 1 To Form1.ChannelList.ListItems.Count
  If frmMain.ChannelList.ListItems.Item(X).Text = Username Then
    frmMain.ChannelList.ListItems.Remove (frmMain.ChannelList.FindItem(Username).Index)
End If
Next X


One problem is you're using a 1 based counting system on a zero based index. Also, I don't see why you need to find the username again to remove it, the index x should contain it if it fulfills the IF condition. Also you should either convert everything to upper case or lower case to compare usernames.


Case ID_LEAVE
For X = 0 To Form1.ChannelList.ListItems.Count - 1
  If UCase(frmMain.ChannelList.ListItems.Item(X).Text) = UCase(Username) Then
    frmMain.ChannelList.ListItems.Remove (X)
    X = X - 1 'Compensate for the removed item
End If
Next X


GoSu_KaOs

Aight.. This works..



Sub RemoveUser()
On Error GoTo error
Dim itm1 As ListItem, itm2 As ListItem
Dim str1 As String, str2 As String

For Each itm1 In frmManagers.lvAliases.ListItems   'loop the first listview
If InStr(1, itm1.Text, ":") Then 'just make sure ":" is in there
  str1 = Left$(LCase(itm1.Text), InStr(1, LCase(itm1.Text), ":") - 1)  'get the leftside of ":"
  str2 = Mid$(LCase(itm1.Text), InStr(1, LCase(itm1.Text), ":") + 1)  'get the rightside of ":"
   
   For Each itm2 In Form1.ChannelList.ListItems  'loop second listview
    If LCase(itm2.Text) = str2 Then  'see if it matches the string
      'itm2.Text = str2 'if it does, change it
      Form1.ChannelList.ListItems.Remove (Form1.ChannelList.FindItem(str2).Index)
    End If
   Next itm2
End If
Next itm1
error:
End Sub


BUT, If I take off the error handler, I get an error, " Control's collection has been modified." and it highlights Next itm2. But when I press play again, it sais," For loop not initialized.".

Will this make a problem or can I just leave it with the errors.

tA-Kane

#12
Quote from: GoSu_KaOs on January 28, 2005, 04:31 PMWill this make a problem or can I just leave it with the errors.
You should always catch and properly handle your errors.

QuoteOn Error GoTo Hell
Macintosh programmer and enthusiast.
Battle.net Bot Programming: http://www.bash.org/?240059
I can write programs. Can you right them?

http://www.clan-mac.com
http://www.eve-online.com

GoSu_KaOs

#13
Can someone tell me why the error is showing up ("Control's collection has been modified")?

MyndFyre

Quote from: GoSu_KaOs on January 29, 2005, 12:39 AM
Can someone tell me why the error is showing up ("Control's collection has been modified")?

Because you're changing the control's collection while inside the For Each statement, which operates on an enumerator.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.