最精简的小写金额转大写的函数
2008-10-13 13:27
309 查看
function Changdx2(mmje: Double): string;
const s1: string = '零壹贰叁肆伍陆柒捌玖';
s2: string = '分角元拾佰仟万拾佰仟亿拾佰仟万';
function StrTran(const S, S1, S2: string): string;
begin
Result := StringReplace(S, S1, S2, [rfReplaceAll]);
end;
var s, dx: string;
i, Len: Integer;
begin
if mmje < 0 then
begin dx := '负';
mmje := -mmje;
end;
s := Format('%.0f', [mmje * 100]);
Len := Length(s);
for i := 1 to Len do
dx := dx + Copy(s1, (Ord(s[i]) - Ord('0')) * 2 + 1, 2) + Copy(s2, (Len - i) * 2 + 1, 2);
dx := StrTran(StrTran(StrTran(StrTran(StrTran(dx, '零仟', '零'), '零佰', '零'), '零拾', '零'), '零角', '零'), '零分', '整');
dx := StrTran(StrTran(StrTran(StrTran(StrTran(dx, '零零', '零'), '零零', '零'), '零亿', '亿'), '零万', '万'), '零元', '元');
if dx = '整' then Result := '零元整'
else Result := StrTran(StrTran(dx, '亿万', '亿零'), '零整', '整');
end;
const s1: string = '零壹贰叁肆伍陆柒捌玖';
s2: string = '分角元拾佰仟万拾佰仟亿拾佰仟万';
function StrTran(const S, S1, S2: string): string;
begin
Result := StringReplace(S, S1, S2, [rfReplaceAll]);
end;
var s, dx: string;
i, Len: Integer;
begin
if mmje < 0 then
begin dx := '负';
mmje := -mmje;
end;
s := Format('%.0f', [mmje * 100]);
Len := Length(s);
for i := 1 to Len do
dx := dx + Copy(s1, (Ord(s[i]) - Ord('0')) * 2 + 1, 2) + Copy(s2, (Len - i) * 2 + 1, 2);
dx := StrTran(StrTran(StrTran(StrTran(StrTran(dx, '零仟', '零'), '零佰', '零'), '零拾', '零'), '零角', '零'), '零分', '整');
dx := StrTran(StrTran(StrTran(StrTran(StrTran(dx, '零零', '零'), '零零', '零'), '零亿', '亿'), '零万', '万'), '零元', '元');
if dx = '整' then Result := '零元整'
else Result := StrTran(StrTran(dx, '亿万', '亿零'), '零整', '整');
end;
相关文章推荐
- 最精简的小写金额转大写的函数
- 最精简的小写金额转大写的函数
- 最精简的小写金额转大写的函数
- 最精简的小写金额转大写的函数
- orcale小写金额转大写函数
- 一个Asp中将小写金额转换为大写的函数
- 【叶子函数分享十八】人民币小写金额转大写
- MSSql 自定义函数实现小写金额转换成大写(最高13位不包括小数点后两位)
- Delphi2010下的小写金额转大写的函数
- JS函数实现金额小写转大写
- 【叶子函数分享十八】人民币小写金额转大写
- 求小写金额转换成大写金额的函数-js
- 用ASP将小写金额转成大写(函数)
- 小写金额转换成大写金额的函数
- 小写金额转换成大写 - 函数脚本
- 我在csdn得分最多的一个帖子:用6行代码写一个将小写金额转成大写的函数
- 金额数值小写转大写函数
- 小写金额转换成大写 - 函数脚本
- [转载]fastreport报表增加自定义函数 小写金额转换为大写
- 金额小写转大写