Currency Formatting with Delphi -
i trying writte code in delphi, displaying given number in currency format this:
now works if filled whole number , field until paramater updated. i'd happy have code displaying number in currency format writte it. i've tried manage typing this:
procedure tform1.editzakladchange(sender: tobject); var zaklad: currency; begin zaklad := strtofloat(editzaklad.text); editzaklad.text := floattostrf(zaklad, ffcurrency, 10, 2); end; end.
but everytime when someting typed in (zaklad field), error appears:
could me that, please?
make sure maxlength of edtzaklad 0.
var form21: tform21; check:string; //to break loop. function getcurrency(num: string):string; var i: integer ; str:string; zaklad: currency; begin result := ''; := 1 length(num) begin if (num[i] in ['0'..'9']) begin str := str + num[i] ; zaklad := strtofloat(str); result := floattostrf(zaklad, ffcurrency, 10, 2); check := result; end; end; end; function extractcurrencysymbol(zaklad: string):string; var i: integer ; str:string; begin result := ''; := 1 length(zaklad) begin if not (zaklad[i] in ['0'..'9','.',',']) begin str := str + zaklad[i]; result := ' '+trim(str); end; end; end; procedure tform21.editzakladchange(sender: tobject); begin if ansipos(check,editzaklad.text) <> 0 exit; if (trim(editzaklad.text) = '') exit else begin editzaklad.text := getcurrency(editzaklad.text)+extractcurrencysymbol(editzaklad.text); exit; end; end;
i hope asked for.
Comments
Post a Comment