Solved

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

Posted on 2009-07-05
5
357 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 50 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 47

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 75 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

Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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 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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

695 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