Solved

Splitting a string with one substring as the first word up until a space, and the rest of the string (spaces included) as the second substring

Posted on 2008-09-30
5
270 Views
Last Modified: 2012-05-05
I have a string with a long name in it.

Example: Paul De La Cruz

I need to split it into first and last names, where first name is the string up until the first space. Last name will be anything that isn't the first name.

str1= Paul
str2 = De La Cruz
0
Comment
Question by:ppdocs
  • 3
  • 2
5 Comments
 
LVL 9

Expert Comment

by:mgonullu
ID: 22608612
http://www.bellaonline.com/articles/art18819.asp

Try the Split function it should work
0
 

Author Comment

by:ppdocs
ID: 22608895
This ended up working, thanks though...

 Dim tmpstr As String = excelvalue
        Dim strlines As String()
        If Len(tmpstr) <> 0 Then
          strlines = tmpstr.Split(" ")
          Dim FirstName As String
          Dim LastName As String = ""

          FirstName = strlines(0)

          For i As Integer = 1 To strlines.Length - 1
            LastName = LastName & strlines(i) & " "
          Next
0
 
LVL 9

Accepted Solution

by:
mgonullu earned 500 total points
ID: 22609326
oops no points??
Moderator what do you say
0
 

Author Closing Comment

by:ppdocs
ID: 31501683
I don't think that copying and pasting a site that I already looked at as being all that helpful, but if the points are that important to you, here you go..
0
 
LVL 9

Expert Comment

by:mgonullu
ID: 22609413
Thank you, points are not important for me, I didn't know that you already looked to my website, I am here to assist only. Thank you again.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

920 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now