sexta-feira, 15 de agosto de 2014

COMO RETIRAR SOMENTE OS NUMEROS DE UMA STRING

Segue uma função básica de como extrair de uma string somente números no formato currency.

function StrToCurr(Texto: String): Currency;
var
  nI: Integer;
  TextoLimpo: String;
begin
  TextoLimpo := '';
  For nI := 1 to Length(Texto) do begin
    if Texto[nI] in ['0'..'9',','] then
       TextoLimpo := TextoLimpo + Texto[nI];
  end;
  Result := StrToCurr(TextoLimpo);
end;