Results 1 to 5 of 5

Thread: [2005] Separation of variable

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Posts
    138

    Unhappy [2005] Separation of variable

    Hello! I need code for separation of one word from array in bracket.

    For example:

    Word1 (Word2)

    What I want, is to separate Word1 on the one side and Word2 on the other side.

    Thanks!

  2. #2
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,950

    Re: [2005] Separation of variable

    So this is a string?

    In which case;
    Code:
            Dim s As String = "Word1 (Word2)"
            Dim a As String = s.Substring(0, s.IndexOf(" "))
            Dim b As String = s.Substring(s.IndexOf("(") + 1, s.Length - s.IndexOf("(") - 2)

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Posts
    138

    Re: [2005] Separation of variable

    Yes, but Word1 and Word2 are variables from textbox! Which code in this case?

  4. #4
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,950

    Re: [2005] Separation of variable

    So this string appears in a TextBox?, is that right?

    Code:
     
            Dim s As String = TextBox1.Text
            Dim a As String = s.Substring(0, s.IndexOf(" "))
            Dim b As String = s.Substring(s.IndexOf("(") + 1, s.Length - s.IndexOf("(") - 2)

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Posts
    138

    Re: [2005] Separation of variable

    Thanks a lot!

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