sábado, 6 de junho de 2009

Como tirar os espaços no início e no final de uma string?

Function Trim(J:String):String; Export;
Begin
While J[Length(J)]=#32 do Dec(J[0]);
If Length(J)>1 then
While (J[1]=' ') do
Begin
Delete(J,1,1);
If Length(J)<=1 then J:='';
end;
Result:=J;
end; {Lembrando que esta é uma função pré-definida pelo delphi.Use-a assim:}

if trim(edit1.Text := '' ) then showmessage('Este edit precisa ser preenchido com caracteres');

Nenhum comentário:

Postar um comentário