Solved

vb.net split

Posted on 2013-06-18
2
341 Views
Last Modified: 2013-06-18
Hello Experts
I am trying to split the customer name into 3 parts to capture title,first and last name separately..

.Name = Node.SelectNodes("DELIVERTO/NAME").Item(0).InnerText

ex: "MRS HELLEN MICHAEL MURRAY"

I want to store the first 2 parts in 2 variables and the rest of the name in 3rd variable

Title = "MRS"
Fname="HELLEN"
Lname= "MICHAEL MURRAY"  


Please can someone advise?

Thanks
0
Comment
Question by:arthur112
[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
  • 2
2 Comments
 
LVL 18

Assisted Solution

by:Cluskitt
Cluskitt earned 500 total points
ID: 39257016
Dim str As String()
Dim sName, Title, Fname, Lname As String
sName = .Name
str = sName.Split(" ")
Title = str(0)
Fname = str(1)
Lname = ""
For a = 2 To str.Length - 1
    Lname = Lname & " "
Next
Lname = Left(Lname, Len(Lname) - 1)

Open in new window

This should work, off the top of my head.
0
 
LVL 18

Accepted Solution

by:
Cluskitt earned 500 total points
ID: 39257020
Probably simpler:
Dim str As String()
Dim sName, Title, Fname, Lname As String
sName = .Name
str = sName.Split(" ")
Title = str(0)
Fname = str(1)
Lname = Replace(sName, Title & " " & Fname & " ", "")

Open in new window

0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

759 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