Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

splitting full name string into first and last

Posted on 2004-08-28
1
Medium Priority
?
214 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

722 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