Solved

splitting full name string into first and last

Posted on 2004-08-28
1
210 Views
Last Modified: 2010-04-15
have a string that contains a full name... for example "john m doe".

need to put "doe" in a string called strLastName and "john m" in string called strFirstName. if the name was "john doe" (without the middle initial), then strLastName would be "doe", and strFirstName would be "john"

if there is a mr/ms/mrs/dr etc. in front of first name, then it should be placed in strFirstName...

please advise on the correct code... thanks!
0
Comment
Question by:loyaliser
1 Comment
 
LVL 22

Accepted Solution

by:
cookre earned 500 total points
ID: 11923736
FirstSpace=FullName.IndexOf(" ");
LastSpace=FullName.LastIndexOf(" ");

FirstWord=FullName.Substring(0,FirstSpace);
LastWord=FullName.Substring(LastSpace+1);
Middle=FullName.SubString(FirstSpace+1,LastSpace-FirstSpace);

I leave it to you to check for:
* honorific or not
* no spaces
* just 1 space
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question