Como formatar uma string em valor monetario?
Pessoal, quero formatar a string em monetario, mais sem ter que usar a forma de dividir por 100 para trazer o resultado
FormatFloat(',0.00', StrtoCurrDef(valor,0)/100);
No exemplo se eu usar a linha comentada o valor fica 2.192.741,00
E preciso que fique igual quando uso a divisão por 100
21.927,41, só que sem o uso do divisor
Algo como contar a quantidade de caracteres e formatar no formato monetário.
Chegeu a ver esta função na net
Mais precisa de tudo isso?
var
valor: string;
begin
valor:= '2192741';
Valor :=
//FormatFloat(',0.00',StrToCurr(Valor));
FormatFloat(',0.00', StrtoCurrDef(valor,0)/100);
ShowMessage(Valor);Function Dollar( c: String ): String ;
var
x: Integer;
t: Integer;
begin
t := Length( c );
Insert( ',', c, t - 1 ); {c := copy(c, 1, 6) + ',' + copy(c, 7, 2) ;}
//Converte zeros em espacos
for x := 1 to t do
if c[x+1] <> ',' then
if x < t - 1 then
if c[x] = '0' then c[x] := ' ' else break;
if Length( Trim( c ) ) <= 3 then c := '0' + Trim( c );
if Length( Trim( c ) ) <= 3 then c := Trim( c ) + '0';
Dollar := c;
end;Adriano Dolce
Curtidas 0