[
][green][/green]看看哥们的,绝对好用!
function SmallTOBig(small: real): string;
var
SmallMonth, BigMonth: string;
wei1, qianwei1: string[2];
qianwei, dianweizhi, qian: integer;
fs_bj: boolean;
begin
if small < 0 then
fs_bj := True
else
fs_bj := False;
small := abs(small);
{------- 修改参数令值更精确 -------}
{小数点后的位置,需要的话也可以改动-2值}
qianwei := -2;
{转换成货币形式,需要的话小数点后加多几个零}
Smallmonth := formatfloat('0.00', small);
{---------------------------------}
dianweizhi := pos('.', Smallmonth);{小数点的位置}
{循环小写货币的每一位,从小写的右边位置到左边}
for qian := length(Smallmonth) downto 1 do
begin
{如果读到的不是小数点就继续}
if qian <> dianweizhi then
begin
{位置上的数转换成大写}
case StrToInt(Smallmonth[qian]) of
1: wei1 := '壹';
2: wei1 := '贰';
3: wei1 := '叁';
4: wei1 := '肆';
5: wei1 := '伍';
6: wei1 := '陆';
7: wei1 := '柒';
8: wei1 := '捌';
9: wei1 := '玖';
0: wei1 := '零';
end;
{判断大写位置,可以继续增大到real类型的最大值}
case qianwei of -3: qianwei1 := '厘'
-2: qianwei1 := '分'
-1: qianwei1 := '角';
0: qianwei1 := '元';
1: qianwei1 := '拾';
2: qianwei1 := '佰';
3: qianwei1 := '仟';
4: qianwei1 := '万';
5: qianwei1 := '拾';
6: qianwei1 := '佰';
7: qianwei1 := '仟';
8: qianwei1 := '亿';
9: qianwei1 := '拾';
10: qianwei1 := '佰';
11: qianwei1 := '仟';
end;
inc(qianwei);
BigMonth := wei1 + qianwei1 + BigMonth;{组合成大写金额}
end;
end;
BigMonth := FastReplace(BigMonth, '零拾', '零', False);
BigMonth := FastReplace(BigMonth, '零佰', '零', False);
BigMonth := FastReplace(BigMonth, '零仟', '零', False);
BigMonth := FastReplace(BigMonth, '零角零分', '', False);
BigMonth := FastReplace(BigMonth, '零角', '零', False);
BigMonth := FastReplace(BigMonth, '零分', '', False);
BigMonth := FastReplace(BigMonth, '零零', '零', False);
BigMonth := FastReplace(BigMonth, '零零', '零', False);
BigMonth := FastReplace(BigMonth, '零零', '零', False);
BigMonth := FastReplace(BigMonth, '零亿', '亿', False);
BigMonth := FastReplace(BigMonth, '零万', '万', False);
BigMonth := FastReplace(BigMonth, '零元', '元', False);
BigMonth := FastReplace(BigMonth, '亿万', '亿', False);
BigMonth := BigMonth + '整';
BigMonth := FastReplace(BigMonth, '分整', '分', False);
if BigMonth = '元整' then
BigMonth := '零元整';
if copy(BigMonth, 1, 2) = '元' then
BigMonth := copy(BigMonth, 3, length(BigMonth) - 2);
if copy(BigMonth, 1, 2) = '零' then
BigMonth := copy(BigMonth, 3, length(BigMonth) - 2);
if fs_bj = True then
SmallTOBig := '- ' + BigMonth
else
SmallTOBig := BigMonth;
end;
FastReplace 只是一个替换函数可用其他的替换