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
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
Question by:ppdocs
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
  • 3
  • 2

Expert Comment

ID: 22608612

Try the Split function it should work

Author Comment

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) & " "

Accepted Solution

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

Author Closing Comment

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..

Expert Comment

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.

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL ( and MongoDB (…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

691 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