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
Printable View
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
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.
What I need is to split the City , state and Zip into seperate fields. Like so
|City|State|Zip|
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.
VB Code:
strAddress = strSplit(strSplitString(2)) 'default is space strCity = strAddress(0) strState = strAddress(1) strZip = strAddress(2)