+ Reply to Thread
Results 1 to 2 of 2

how to split a string and return array

  1. #1
    Registered User
    Join Date
    12-08-2005
    Posts
    13

    how to split a string and return array

    VBA code question:
    how can I use split function to break a string and then retun the results to array?

    for example:
    a string: Prince William, Manassas + Manassas Park,[51942]
    separator:comma , and plus sign +
    results would be something like :
    Myarray = (Prince William, Manassas, Manassas Park,[51942])
    I think I have to Trim each element in Myarray before building Myarray.

    since the string will change, the upperbound of Myarray will change also.

    any help or idea will be appreciated!!
    thanks for any response

  2. #2
    Bob Phillips
    Guest

    Re: how to split a string and return array

    Dim sTest As String
    Dim aParts
    sTest = "Prince William, Manassas + Manassas Park,[5192]"
    aParts = Split(Replace(sTest, "+", ","), ",")


    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    "xiang" <[email protected]> wrote in
    message news:[email protected]...
    >
    > VBA code question:
    > how can I use split function to break a string and then retun the
    > results to array?
    >
    > for example:
    > a string: Prince William, Manassas + Manassas
    > Park,[51942]
    > separator:comma , and plus sign +
    > results would be something like :
    > Myarray = (Prince William, Manassas, Manassas Park,[51942])
    > I think I have to Trim each element in Myarray before building
    > Myarray.
    >
    > since the string will change, the upperbound of Myarray will change
    > also.
    >
    > any help or idea will be appreciated!!
    > thanks for any response
    >
    >
    > --
    > xiang
    > ------------------------------------------------------------------------
    > xiang's Profile:

    http://www.excelforum.com/member.php...o&userid=29489
    > View this thread: http://www.excelforum.com/showthread...hreadid=493338
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1