Results 1 to 5 of 5

Thread: split question

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2003
    Posts
    92

    split question

    I have a string that looks like this:

    Company|Address|City State Zip|other info


    I need to split the City State and Zip into seperate fields using "|"

    The state is always 2 letters
    City is not always one word


    How can I do this?
    Thanks

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Code:
    Dim strMyString as String
    Dim strSplitString() as String
    
    strMyString = "Company|Address|City State Zip|other info"
    
    strSplitString = strMyString.Split("|")
    
    'strSplitString now contains an array of strings that were split.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 2003
    Posts
    92

    Not what I am looking for

    What I need is to split the City , state and Zip into seperate fields. Like so

    |City|State|Zip|

  4. #4
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840

    Hellswraith's example

    You can still use Hellwraith's example.

    If you use his split example you know that strSplitString(2)=City State Zip

    If the state is allways 2 letters and I'm guessing that the zipcode is also allways the same
    length (unless the info is from different countries), you should be able to pick those out, and
    whatever is left must be the city.
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

  5. #5
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950
    VB Code:
    1. strAddress = strSplit(strSplitString(2))  'default is space
    2. strCity = strAddress(0)
    3. strState = strAddress(1)
    4. strZip = strAddress(2)

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