Results 1 to 6 of 6

Thread: Split String

  1. #1

    Thread Starter
    Addicted Member Tha Joey Madnez's Avatar
    Join Date
    May 2004
    Location
    Netherlands
    Posts
    179

    Resolved Split String

    Hi,

    How can i read 3 strings behind a word.

    Example: !Connect Serv 1204 Pass
    Then how can i split it so i can read
    the 3 words behind !Connect and i can put
    them in a string

    serv = Serv
    Port = 1204
    Pass = Pass

    Srry for my bad english, im from holland


    Code i have:

    VB Code:
    1. If Left(Message, 7) = "!Connect" Then
    2.     Dim String As String
    3.     a = Message
    4.     b = " "
    5.     If Left(a, 7) = "!Connect" Then
    6.     c = Split(a, b)
    7.     String = c(1)
    8.     sendmsg string
    9.     End If
    10.     End If

    In the code above, i can only get 1 string behind the word


    thx !
    Last edited by Tha Joey Madnez; Feb 19th, 2005 at 05:00 AM.
    100% Done with the Software forLuidia

    Click here to goto the Luidia website

    -=[Visual Basic][Addicted]=-

  2. #2
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: Split String

    Quote Originally Posted by Tha Joey Madnez
    Hi,

    How can i read 3 strings behind a word.

    Example: !Connect Serv 1204 Pass
    Then how can i split it so i can read
    the 3 words behind !Connect and i can put
    them in a string

    serv = Serv
    Port = 1204
    Pass = Pass

    Srry for my bad english, im from holland


    Code i have:

    VB Code:
    1. If Left(Message, 7) = "!Connect" Then
    2.     Dim String As String
    3.     a = Message
    4.     b = " "
    5.     If Left(a, 7) = "!Connect" Then
    6.     c = Split(a, b)
    7.     String = c(1)
    8.     sendmsg string
    9.     End If
    10.     End If

    In the code above, i can only get 1 string behind the word


    thx !

    VB Code:
    1. myString = "!Connect Serv 1204 Pass"
    2.  
    3. myArray = Split(mystring, " ")
    4.  
    5. MsgBox myarray(0) ' would contain !Connect
    6. MsgBox myarray(1)
    7. MsgBox myarray(2)
    8. Msgbox MyArray(3)

    and whalla there stored in the array

    Hope that helps

    Edit - for your code....

    VB Code:
    1. If Left(Message, 7) = "!Connect" Then
    2.    Dim myString As String
    3.    a = Message
    4.       If Left(a, 7) = "!Connect" Then
    5.            c = Split(a, " ")
    6.            myString = c(1) ' this would hold port
    7.     sendmsg mystring
    8.     End If
    9.     End If
    Last edited by Pino; Feb 19th, 2005 at 04:44 AM.

  3. #3

    Thread Starter
    Addicted Member Tha Joey Madnez's Avatar
    Join Date
    May 2004
    Location
    Netherlands
    Posts
    179

    Unhappy Re: Split String

    Edit: I dint saw the code beneath it, i will test now


    THX For reply !
    But it doesnt work with me
    100% Done with the Software forLuidia

    Click here to goto the Luidia website

    -=[Visual Basic][Addicted]=-

  4. #4
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: Split String

    Quote Originally Posted by Tha Joey Madnez
    Edit: I dint saw the code beneath it, i will test now


    THX For reply !
    But it doesnt work with me
    Show me the code you are using?

    VB Code:
    1. myString = "!Connect Serv 1204 Pass"
    2.  
    3. MyArray = Split(myString, " ")
    4.  
    5. MsgBox MyArray(0) ' would contain !Connect
    6. MsgBox MyArray(1) 'contains the serv
    7. MsgBox MyArray(2) 'contains the port
    8. MsgBox MyArray(3) 'contains the pass

    use that to impliment into your app.

    Let me see your code.

  5. #5

    Thread Starter
    Addicted Member Tha Joey Madnez's Avatar
    Join Date
    May 2004
    Location
    Netherlands
    Posts
    179

    Talking Re: Split String

    I got it to work
    I forgot something,

    this dint work because of the 7, connect contains 8 characters
    VB Code:
    1. If Left(Message, 7) = "!Connect" Then

    This works
    VB Code:
    1. If Left(Message, 8) = "!Connect" Then

    Thx
    100% Done with the Software forLuidia

    Click here to goto the Luidia website

    -=[Visual Basic][Addicted]=-

  6. #6
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: Split String

    Quote Originally Posted by Tha Joey Madnez
    I got it to work
    I forgot something,

    this dint work because of the 7, connect contains 8 characters
    VB Code:
    1. If Left(Message, 7) = "!Connect" Then

    This works
    VB Code:
    1. If Left(Message, 8) = "!Connect" Then

    Thx
    Arr ok no problem glad you solved it. If you are curious of functions like this have a look in my sig on useful vb functions i have a few covered there.

    If you could mark this resolved that would be great

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