Solved

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

Posted on 2009-07-05
5
345 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
5 Comments
 
LVL 5

Assisted Solution

by:rizwanidrees
rizwanidrees earned 50 total points
Comment Utility
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 47

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 75 total points
Comment Utility
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
Comment Utility
Both approaches above work well for this many thanks.
0
 
LVL 4

Expert Comment

by:stevepicks
Comment Utility
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
Comment Utility
OK thanks Stevepicks will use split for this.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

728 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

11 Experts available now in Live!

Get 1:1 Help Now