parsing full name

parsing full name

Anonymous
Not applicable
484 Views
4 Replies
Message 1 of 5

parsing full name

Anonymous
Not applicable
Trying to parse a persons full name to return with a
firstInitial Lastname. If Frank L. Couger,
it will return with a F Couger

Here is my code but does wotk right.
Can someone fix it?

Dim FullName As String
Dim first, last, name, fi As String
Dim pos, L As Integer

FullName = DSLENGR_Replace
If FullName = DSLENGR_Replace Then

pos = InStr(FullName, " ")
If pos = 0 Then
first = FullName
Else
first = Left(FullName, pos - 1)
End If


fi = Left(first, 1)

L = Len(FullName)
last = Right(FullName, L - 1)

ENG_NAME_Replace = fi & " " & last
Me.ENG_NAME_Replace = UCase(Me.ENG_NAME_Replace)
0 Likes
485 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
i hope this helps . . .

Public Function parseName(nameOld As String) As String
Dim spos As Long
Dim slen As Long
parseName = Left(nameOld, 1) & " "

spos = InStrRev(nameOld, " ")
slen = Len(nameOld)

parseName = parseName & Right(nameOld, slen - spos)
parseName = UCase(parseName)
End Function

gooms
0 Likes
Message 3 of 5

Anonymous
Not applicable
> Can someone fix it?

Try this:

' Assumes the passed name will always be in the
' format First M. Last
Public Function Test(Name As String) As String

Dim tokens

tokens = Split(Name, " ")
Test = Left$(tokens(0), 1) & " " & tokens(UBound(tokens))

End Function

--
There are 10 kinds of people:
Those who understand binary and those who don't
http://www.acadx.com
http://vbxtender.sourceforge.net
0 Likes
Message 4 of 5

Anonymous
Not applicable
whats the split function Frank
Frank Oquendo wrote in message
news:D4FD72C1350219EE966FEB148AB3F324@in.WebX.maYIadrTaRb...
> > Can someone fix it?
>
> Try this:
>
> ' Assumes the passed name will always be in the
> ' format First M. Last
> Public Function Test(Name As String) As String
>
> Dim tokens
>
> tokens = Split(Name, " ")
> Test = Left$(tokens(0), 1) & " " & tokens(UBound(tokens))
>
> End Function
>
> --
> There are 10 kinds of people:
> Those who understand binary and those who don't
> http://www.acadx.com
> http://vbxtender.sourceforge.net
>
>
0 Likes
Message 5 of 5

Anonymous
Not applicable
Joe C. Parker had this to say
:
> whats the split function Frank
> Frank Oquendo wrote in message

Starting with VBA6 (AutoCAD 2000i or better), it's a native VBA function
that will parse a string into individual tokens using the supplied
delimiter. In the example I gave earlier, "Joe C. Parker" would become
"Joe" "C." "Parker".

For AutoCAD 2000 or earlier, you can use this replacement function
instead:
http://code.acadx.com/visualbasic/043.htm

--
There are 10 kinds of people:
Those who understand binary and those who don't
http://www.acadx.com
http://vbxtender.sourceforge.net
0 Likes