Breaking apart a string

C

Charlie

I have a string (strSentence) that my code has copied off the Word document
and I know that it’s setup with this format:
John & Jane Doe <tab>Jim, Anne <tab> 1,2,3

The first part of the sentence is a name, either first & last or first,
wife, and last.
Then a tab
Then a sequence of one to four names separated by “,â€
Then a tab
The a sequence of a few numbers separated by “,â€

How can I programmatically break this down into the following 3 strings:
Name (everything before the first tab)
Children (everything between the tabs)
Number (everything after the second tab)

Thanks,
Ck
 
T

Tony Jollans

Try using Split (assuming you have at least Word 2000) ...

Dim Phrases ' must be defined as a variant
Phrases = Split(strSentence,vbTab)

Msgbox Phrases(0) ' so you can see what they are
Msgbox Phrases(1)
Msgbox Phrases(2)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top