Format関数を用いて浮動小数点値を通貨形式に変換しているのですが、
その逆はどのようにすればいいのでしょうか。
Edit.Text := Format('%m',[StrToFloat(Edit.Text)]);
StrToCurr関数とかで通貨形式にします。
多分に説明不足でした。
申し訳ないです。
Edit.Text := Format('%m',[StrToFloat(Edit.Text)]);
を用いて、\1,000という文字列に形式化しているのですが、
この\1,000を1000という文字列に変換するにはどのようにすればいいのでしょうか。
function PriceToNumber1(const price:string):string;
begin
result := StringReplace(StringReplace(price,'\','',[rfReplaceAll]),
',','',[rfReplaceAll]);
end;
function PriceToNumber2(const price:string):string;
var
i:integer;
begin
result := price;
for i := Length(price) downto 1 do
if result[i] in ['\',','] then delete(result,i,1);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Label1.Caption := PriceToNumber1('\1,000');
Label2.Caption := PriceToNumber2('\1,000');
end;
jokさん、ありがとうございます。
PriceToNumber2を使用させていただきます。
ありがとうございました。
忘れてました。
ツイート | ![]() |