Results 1 to 8 of 8

Thread: Split?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2007
    Posts
    520

    Split?

    I am trying to figure out the "split", but, another option could be great too.


    String to divide up: SETUP|variable1&Variable2

    Now, in split, each one i've seen uses the 'foreach' statement in all of the examples.

    I dont want the 'foreach', i want to be able to pull the variable1...and the variable2.

    I know I can do the replace to ditch the SETUP|, so more so, how to pull to the left, and the right..of &

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

    Re: Split?

    So what's the general pattern? Will it always be a value followed by a pipe followed by a value followed by an ampersand followed by a value, or could it be something different?
    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

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2007
    Posts
    520

    Re: Split?

    the & will be the divider.


    So it'll be blahblahblah&yaydedodork

    Each example i saw uses foreach...

    I want to just pull the blahblahblah, or the yaydedodork... which change...

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

    Re: Split?

    You've now contradicted yourself. Your first post shows a pipe and your second doesn't. You need to be CLEAR. If we don't know what you actually want then we can't help you achieve it.
    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
    Fanatic Member
    Join Date
    Nov 2007
    Posts
    520

    Re: Split?

    I didnt contradict myself...

    2 variables, seperated with a &...

    In all the examples, they use a "foreach" command... ok, i got that.

    BUT, how do I pull to the left...or to the right of the &? and not the other

  6. #6
    PowerPoster Evil_Giraffe's Avatar
    Join Date
    Aug 2002
    Location
    Suffolk, UK
    Posts
    2,555

    Re: Split?

    Have you looked at the documentation for the Split method rather than just examples? That should help you along your way.

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

    Re: Split?

    You did contradict yourself, but I'm not sure it matters. Have you checked the documentation for the String.Split method to see what it returns? Think about it. You say that the examples you've seen use a foreach loop. What are foreach loops usually used with? Arrays and collections, right? How do you usually get items by index from an array or collection?
    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
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497

    Re: Split?

    TCarter - what's the code you've tried that's not working?

    If you don't know where to start, start with google and a search like this:

    C# Split Examples
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

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