PDA

View Full Version : split string into names


reubenb
07-18-2008, 09:04 AM
hey

i have a 'full name' field, which they could enter 'Firstname Midname Lastname' or 'Firstname Lastname'.

I need the last word to be 'lastname', and the first two words to be 'firstname'... for the first option
and
I need the last word to be 'lastname', and the first word to be 'firstname'... for the second option

but it may not always have 3 words, so how would i do this?

this is what i have so far..

Dim arrayname
arrayname = Split(db_field), " ")

but will only arrayname(0) and arrayname(1) would work, but it would die if i had arrayname(2) and it doesnt exist?

Spudhead
07-18-2008, 12:16 PM
Then check to see how many names are in your array using uBound(arrayname). If the uBound is 2, you've got 3 names.

reubenb
07-19-2008, 08:37 PM
of course! great - thank you very much