?
Solved

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

Posted on 2009-07-05
5
Medium Priority
?
358 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 47

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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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…
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…
Suggested Courses
Course of the Month14 days, 6 hours left to enroll

771 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