首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

货币转换成大写字符 有关问题

2012-02-06 
货币转换成大写字符问题我要合并字符串,使用那个函数啊?比如把‘零零’变成‘零’我在做货币转换成大写字符,那

货币转换成大写字符 问题
我要合并字符串,
使用那个函数啊?
比如
    把‘零零’变成‘零’

我在做货币转换成大写字符,
那位还有更好的算法?
比如把
  100502.51
        转换成
  拾万零伍佰零贰点伍壹

[解决办法]

function SmallToBig(small: double): string;
const
weis = '零壹贰叁肆伍陆柒捌玖 ';
qianweis = '分角元拾佰仟万拾佰仟亿十佰仟 ';
var
decPos: Integer;
I, Len, n, m: Integer;
SmallMonth: string;
begin
SmallMonth := FormatFloat( '0.00 ', small);
Len := Length(SmallMonth);
DecPos := Pos( '. ', SmallMonth);
n := 0;
Result := ' ';
for I := Len downto 1 do
begin
if I = DecPos then continue;
m := (Ord(SmallMonth[I]) - 48) * 2 + 1;
Result := Copy(weis, m, 2) + Copy(qianweis, n * 2 + 1, 2) + Result;
Inc(n);
end;
end;

procedure TForm1.Button1Click(Sender: TObject);

begin
ShowMessage(SmallToBig(1234567890.12));
end;

热点排行