Results 1 to 14 of 14

Thread: Mid left right

  1. #1

    Thread Starter
    Hyperactive Member OMITT3D's Avatar
    Join Date
    Mar 2006
    Posts
    368

    Mid left right

    I used to use
    Nick = Left$(IrcRead(0), InStrRev(IrcRead(0), "!") - 1)
    Nick = Mid$(Nick, InStrRev(Nick, ":") + 1)
    to get the Nick of someone in IRC but now in .net it says left is an unknown function cause someone help me witht his IrcRead(0) would be something like this :[email protected]

  2. #2
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Mid left right

    If you know how to use Mid, check out Substring..If you dont, well check out substring

    Nick = Nick.Substring(0,5)

  3. #3

    Thread Starter
    Hyperactive Member OMITT3D's Avatar
    Join Date
    Mar 2006
    Posts
    368

    Re: Mid left right

    Yea but the only constant thing to go off of is ! and @ the others will vary in letters and number of letters.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Mid left right

    The equivalent of InStr and InStrRev are String.IndexOf and String.LastIndexOf. That will allow you to do basically what you are now without Runtime functions.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Hyperactive Member OMITT3D's Avatar
    Join Date
    Mar 2006
    Posts
    368

    Re: Mid left right

    Aren't those just to see if that field is inside of the string? I need to make the string Nick = Rub3X in that case.

  6. #6
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Mid left right

    Test this, okay?

    VB Code:
    1. Dim Name As String = ":[email protected]"
    2.         Name = Name.Substring(0, Name.IndexOf("!"c))

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Mid left right

    IndexOf will give you the index of the first occurence of a character or substring, while LastIndexOf will give you the index of the last occurrence. You can use the results of those methods to calculate the parameters to pass to Substring, which is exactly how InStrRev is being used in the code you originally posted.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  8. #8

    Thread Starter
    Hyperactive Member OMITT3D's Avatar
    Join Date
    Mar 2006
    Posts
    368

    Re: Mid left right

    Hehe ty it worked =)

  9. #9
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Mid left right

    Cool. Don't forget to resolve your thread from the Thread Tools menu.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  10. #10
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: Mid left right

    And the old vb6 string functions are in the Strings module... (although it is best to use the above mentioned methods, this is just to give me something to post about )

    Strings.Left
    Strings.Right
    ... etc

  11. #11

    Thread Starter
    Hyperactive Member OMITT3D's Avatar
    Join Date
    Mar 2006
    Posts
    368

    Re: Mid left right

    erm I am actually having troubles now with that code. I am making an IRC bot and when I try and connect it says
    Attempting connection to irc.cyber-knowledge.net....
    Connected to server.
    Error: Length cannot be less than zero.
    Parameter name: length
    Error: Length cannot be less than zero.
    Parameter name: length
    [email protected] MODE #main +v DotNetBotPort

    In the textbox. It still connects but certain commands don't work...:S Everytime I send the variable Nick to the server it says that.

  12. #12
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Mid left right

    Give us some code!

  13. #13

    Thread Starter
    Hyperactive Member OMITT3D's Avatar
    Join Date
    Mar 2006
    Posts
    368

    Re: Mid left right

    Ok here is the code. I commented out the Nick parse stuff for now and replaced it with just Rub3X for now since that is my IRC nick. I am trying to make the login for it but as you can see I am having trouble. I don't know exactly how to use the IP and check if the person who is typing .login has the same IP as the one logged in. And tbh I doubt you will understand it since it mostly deals with raw IRC commands. Is there a way to pause just what happens in ONE sub while the program continues? Cause...
    VB Code:
    1. ElseIf C(3) = ":" & Prefix & "remove" & Chr(13) Then
    2.                         wsClient.SendData(wsClient.StringToBytes("USERIP Rub3X" & vbCrLf))
    3.                         If TyperIP = UserIP Then
    4.                             wsClient.SendData(wsClient.StringToBytes("PRIVMSG " & IrcChan & " :Removing bot please wait..." & vbCrLf))
    5.                             wsClient.SendData(wsClient.StringToBytes("QUIT" & " :Leaving" & vbCrLf))
    6.                             End

    That trys to compare the person's IP who is typing vs the UserIP which is the IP of the user logged in. But in order to do this you need to send the USERIP raw command and by the time i can do that it's too late and it's already went into a false value of that makes any sense. So I think if I can pause just what is happening in one sub it will work.
    Last edited by OMITT3D; Mar 20th, 2006 at 10:45 PM.

  14. #14

    Thread Starter
    Hyperactive Member OMITT3D's Avatar
    Join Date
    Mar 2006
    Posts
    368

    Re: Mid left right

    Nvm that won't even work cause i did something just to test it

    ElseIf C(3) = ":" & Prefix & "remove" & Chr(13) Then
    wsClient.SendData(wsClient.StringToBytes("USERIP Rub3X" & vbCrLf))
    Dim z As Long
    z = "0"
    Do Until z > 699999999
    z = z + 1
    Loop
    If TyperIP = UserIP Then
    wsClient.SendData(wsClient.StringToBytes("PRIVMSG " & IrcChan & " :Removing bot please wait..." & vbCrLf))
    wsClient.SendData(wsClient.StringToBytes("QUIT" & " :Leaving" & vbCrLf))
    End
    End If

    and all it did was execute the loop first then it did Case "340" after that so idk how to do it =s

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width