[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

How do I separate the firstname for the lastname? firstname.lastname

Posted on 2009-07-05
5
Medium Priority
?
360 Views
Last Modified: 2013-11-07
At the moment my application stored the userlogin which is made up of the firstname.lastname how do I separate these out to get firstname lastname?
firstname.lastname

Open in new window

0
Comment
Question by:adypips
[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
5 Comments
 
LVL 5

Assisted Solution

by:rizwanidrees
rizwanidrees earned 200 total points
ID: 24779101
dim wSP as long, wFirstName as string, wLastName as string
wSP = INSTR(1, UserName, ".")
if wSP>0 then
wFirstName=Left(UserName, wSP-1)
wLastName = Right(UserName, Len(UserName)-wSP)
endif
0
 
LVL 48

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 300 total points
ID: 24779108
Use the String.Split method -> http://msdn.microsoft.com/en-us/library/system.string.split.aspx

Wayne
Dim fullName As String = "firstname.lastname"
Dim firstName As String = fullName.Split("."c)(0)
Dim lastName As String = fullName.Split("."c)(1)

Open in new window

0
 

Author Comment

by:adypips
ID: 24779121
Both approaches above work well for this many thanks.
0
 
LVL 4

Expert Comment

by:stevepicks
ID: 24779122
if there is the . in all records then try split. if there is the space or a capital letter you could also split
example:
Dim userlogin As String = "first.second"
        Dim arrData As Array
        arrData = userlogin.Split(".") 'userlogin.Split(userlogin, ".")
        Dim firstname As String = arrData(0)
        Dim lastname As String = arrData(1)
        MsgBox(firstname & " " & lastname)
0
 

Author Comment

by:adypips
ID: 24779139
OK thanks Stevepicks will use split for this.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

656 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