Remove part of string

  • Thread starter Thread starter JackpipE
  • Start date Start date
J

JackpipE

I have First Name and Middle Name all in one field: |Jack Fred| - How
can I remove the middle name ie: Fred from this string? There could
also be just First Name or First Name and middle initial only.

Thanks,
Jack
 
hi Jack,
I have First Name and Middle Name all in one field: |Jack Fred| - How
can I remove the middle name ie: Fred from this string? There could
also be just First Name or First Name and middle initial only.
Use InStr() and Left():

Public Function FirstWord(AString As String) As String

Dim SpacePos As Long

SpacePos = InStr(ASrting, " ")
If SpacePos > 0 Then
FirstWord = Left(AString, SpacePos)
Else
FirstWord = AString
End If

End Function

But I'm not sure if this works for all kind of names.


mfG
--> stefan <--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top