Solved

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

Posted on 2009-07-05
5
350 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
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

777 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