Fórum Primeiro e ultimo nome da String #342207
22/05/2007
0
Alguem ae conhece alguma função para pegar o nome e ultmimo nome de uma STRING????
Ex.:
STRING:= CARLOS SILVA PEREIRA
Apos aplicar a função a STRING fica assim: CARLOS PEREIRA
Abraço
Nango Xus
Curtir tópico
+ 0Posts
22/05/2007
Marco Salles
function PrimeiroUltimoNome(texto:string):string; var primeiro,ultimo:string; indice,fim:integer; begin texto:=Trim(texto); indice:=pos(´ ´,texto); primeiro:=copy(texto,1,indice); while indice > 0 do begin fim:=indice; indice:=PosEx(´ ´,texto,indice+1); end; Ultimo:=copy(texto,fim,length(texto)); result:=primeiro+´ ´+ultimo; end;
Gostei + 0
23/05/2007
Nango Xus
:D :D :D Muito obrigado funcionou perfeitamente!!! :D :D :D
Gostei + 0
23/05/2007
Ara.es
function TForm1.PrimeiroUltimoNome(Value: String): String; var retorno : String; begin retorno := ´´; retorno := copy(Value,0,pos(´ ´,Value)-1); retorno := retorno + ´ ´ + copy(Value,LastDelimiter(´ ´,Value),length(Value) - LastDelimiter(´ ´,Value) + 1); Result := retorno; end;
Gostei + 0
23/05/2007
Marco Salles
bommmmmm
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)