Link to home
Start Free TrialLog in
Avatar of dtucker
dtucker

asked on

separateing first and last names

I have a database field that consists of first and last names. I would like to retrieve the first name and the last name separately. Using VB4 16 bit, how would I go about retrieving first name and last name so I have two fields, first and last?
ASKER CERTIFIED SOLUTION
Avatar of rondeauj
rondeauj

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of traygreen
traygreen

Several things to consider, but basically (assuming first <space>last)
iSpacePos = Instr(sCombinedName, " ")
if iSpacePos > 0 then
  FName = mid(sCombinedName, 1, iSapcePos)
  LName = mid(sCombinedName, iSpacePos + 1)
else
  FName = sCombinedName
endif

if Last name <comma> first name....

icommapos = instr(sCombinedName, ",")
if icommapos > 0 then
  LName = mid(sCombinedName, 1, iCommaPos)
  FName = mid(sCombinedName, iCommaPos + 1)
else
  LName = sCombinedName
end if

If you have another format, let me know what it is