Fórum Como posso retirar somente os numeros de uma String? #205197
08/01/2004
0
Marcusbraga
Curtir tópico
+ 0Post mais votado
08/01/2004
Na verdade as funções disponíveis do Delphi não conseguem converter string que contenham separadores de milhares e símbolos de moedas. Preparei uma pequena função para resolver o seu problema:
function TextToCurr(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;
Aroldo Zanela
Gostei + 2
Mais Posts
09/01/2004
Alexdias
SE A RESPOSTA FOR SIM ... ENTÃO NÃO TENTE CALCULAR ASSIM .
EX 1 ==>dbedit1.text:= dbedit1.text+dbedit2.text; ( erro )
ex 2 ==> query1.fieldbyname(´valor1´).value:=query1.fieldbyname(´valor1´).value+query1.fieldbyname(´valor2´).value;
dbedit.text:=floattostr(query1.fieldbyname(´valor1´).value);
obs : use variaveis para facilitar e encurtar o codigo ;
espero que sirva !!!
Gostei + 0
09/01/2004
Marcusbraga
function TextToCurr(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;
Gostei + 1
Clique aqui para fazer login e interagir na Comunidade :)