function StrToComma(cur: String): String; overload;
function StrToComma(cur: String; DD: Integer): String; overload;
function CommaToStr(cur: String): String;
function StrToComma(cur: String): String; overload;
begin
result := FormatFloat('#,##0', StrToFloat(cur));
end;
function StrToComma(cur: String; DD: Integer): String; overload;
begin
result := FormatFloat('#,##0.' + StringOfChar('0', DD), StrToFloat(cur));
end;
function CommaToStr(cur: String): String;
const
NumTable = ['0' .. '9', '-', '.'];
var
dst: String;
i: Byte;
CFlg: Boolean;
begin
for i := 1 to Length(cur) do
// '0'..'9','-','.'以外は無視
if (cur[i] in NumTable) then
begin
CFlg := True;
// '-'が先頭の時以外は無視
if (cur[i] = '-') and (i > 1) then
CFlg := False;
// '.'2個目以降は無視
if (cur[i] = '.') and (Pos('.', dst) > 0) then
CFlg := False;
if CFlg then
dst := dst + cur[i];
end;
if (Length(dst) = 0) then
result := '0'
else
result := dst;
end;
|