I am using Word 97 and I want to be able to pickup a
person surname from their full name which has previously
been stored with a string entitled sName.

Can someone assist me please

Thanks

Mark

Re: Separating a string by Jay

Jay
Sat Dec 06 10:41:19 CST 2003

"Mark" <anonymous@discussions.microsoft.com> wrote:

>I am using Word 97 and I want to be able to pickup a
>person surname from their full name which has previously
>been stored with a string entitled sName.
>

Hi, Mark,

You'll need to supply some more details:

- In sName, is the surname stored at the beginning or at the end?
- Is there some unique character such as a comma between the parts of
the name, or are they separated with ordinary spaces?
- How can you tell whether the surname has one, two, three or more
words (John Smith, John von Schmidt, John van der Linden)?


--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://www.mvps.org/word

Re: Separating a string by anonymous

anonymous
Sat Dec 06 11:44:21 CST 2003


The surname is at the end of the name, the names are
generally separated with spaces. I don't think there are
many names tht are double barrelled, there may be one or
two surnames which are hyphenated.

Mark

>-----Original Message-----
>"Mark" <anonymous@discussions.microsoft.com> wrote:
>
>>I am using Word 97 and I want to be able to pickup a
>>person surname from their full name which has
previously
>>been stored with a string entitled sName.
>>
>
>Hi, Mark,
>
>You'll need to supply some more details:
>
>- In sName, is the surname stored at the beginning or at
the end?
>- Is there some unique character such as a comma between
the parts of
>the name, or are they separated with ordinary spaces?
>- How can you tell whether the surname has one, two,
three or more
>words (John Smith, John von Schmidt, John van der
Linden)?
>
>
>--
>Regards,
>Jay Freedman
>Microsoft Word MVP FAQ: http://www.mvps.org/word
>.
>

Re: Separating a string by Helmut

Helmut
Sat Dec 06 16:25:39 CST 2003

Hi Mark,
this might may help you,
but without rules on what is in "aName",
there can be no perfect solution.
Dim aName As String
Dim bName As String
aName = "Smith, John-John"
bName = Right(aName, Len(aName) - InStr(aName, " "))
MsgBox "[" & bName & "]"
Brackets for testing in oder to detect
leading or trailing blanks.

Greetings from Bavaria, Germany
Helmut Weber
"red.sys" & chr$(64) & "t-online.de"


Re: Separating a string by Martin

Martin
Sat Dec 06 16:59:14 CST 2003

> MsgBox "[" & bName & "]"
> Brackets for testing in oder to detect
> leading or trailing blanks.

You can always use the Trim-function to get rid of leading
or trailing blanks:

LTrim(...) removes leading blanks (*left* trim)
RTrim(...) removes trailing blanks (*right* trim)
Trim(...) removes both


Cheers,

Martin



Re: Separating a string by Helmut

Helmut
Sun Dec 07 05:39:25 CST 2003

Hi Martin,
thank you for the advice, but I would like to see
in the messagebox whether the preceeding
routine did, what I was expecting. Simply trimming
blanks doesn't tell me, whether there was something
to trim at all.
Greetings from bavaria.
Helmut Weber



Re: Separating a string by Martin

Martin
Mon Dec 08 01:05:06 CST 2003

Hi Helmut

> [...] Simply trimming blanks doesn't tell me, whether there
> was something to trim at all.

So, why don't you just compare the "untrimmed" string length
to the trimmed one?

bName = Right(aName, Len(aName) - InStr(aName, " "))
uLen = Len(bName)
bName = Trim(bName)
tLen = Len(bName)
If uLen > tLen Then
...

Could also do that with LTrim or RTrim to get the number of leading/
trailing blanks...


Just an idea ;-) Cheers,

Martin