Link to home
Start Free TrialLog in
Avatar of ppdocs
ppdocs

asked on

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

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
Avatar of mgonullu
mgonullu
Flag of United Arab Emirates image

http://www.bellaonline.com/articles/art18819.asp

Try the Split function it should work
Avatar of ppdocs
ppdocs

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of mgonullu
mgonullu
Flag of United Arab Emirates image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ppdocs

ASKER

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