Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

split string

Status
Not open for further replies.

andyc209

IS-IT--Management
Dec 7, 2004
98
GB
I have a batch of names with different numbers of words
e.g.

Mr Joe Bloggs
Mr Smith
Mr James jones

I was going to use Split

Dim surnamearray
surnamearray = Split(surnamesplit, " ")

but how can I make sure I get the last entry in the array as some have only 2 words or some have 3?

So if I use surnamearray(2) it will not work in some cases as the last name will be surnamearray(1)

how can I do this
 
ubound will return an integer representing the largest/last array element

uBound(surnamearray) will return an integer,

so try...

surnamearray(ubound(surnamearray))



Parsing names is VERY UGLY because the last element in your array may not necessarily be a last name. Ex:

Billy Joe Jim-Bob Whosit Jr.


-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Big George's solution is probably much better than the bizareness I was going to suggest:

dim namer, reversed, unreversed, surnamearray
namer = "mr joe jones"
reversed = (StrReverse(namer))
surnamearray = Split(reversed)
unreversed = StrReverse(surnamearray(0))

My "solution" wouldn't pick up "Jr." or "III" as George suggests.


 
thanks for the tips, luckily i think my db does not have jnr or III on the names so this should work great.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top