Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

splitting full name string into first and last

Posted on 2004-08-28
1
Medium Priority
?
218 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 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

783 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