转换大写金额 ( 积分: 100 )

  • 主题发起人 whb01321
  • 开始时间
W

whb01321

Unregistered / Unconfirmed
GUEST, unregistred user!
各位大侠请教一下如何将数字转换为大写的文字
 
对照表(零,壹。。。。)
 
function TForm1.Switch(Value: Real): String;
const
ChnUnit: array[0..13] of string = ('分', '角', '元', '拾', '佰', '仟', '万', '拾', '佰', '仟', '亿', '拾', '佰', '仟');
ChnNum : array[0..9] of string = ('零', '壹','贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖');
var
I: Integer;
StrValue, StrNum: String;
ValueLen: Integer;
begin
if Value <= 0 then
begin
Result := '输入参数应大于零。';
Exit;
end;
StrValue := IntToStr(Round(Value * 100));
ValueLen := Length(StrValue);
Result := '';
for I := 1 to ValueLendo
begin
StrNum := StrValue;
Result := Result + ChnNum[StrToInt(StrNum)] + ChnUnit[ValueLen - I];
end;
if (StrToInt(StrValue[ValueLen])= 0) and (StrToInt(StrValue[ValueLen-1])= 0) then
begin
Result := StringReplace(Result, '零分', '', [rfReplaceAll]);
Result := StringReplace(Result, '零角', '整', [rfReplaceAll]);
end
else
begin
Result := StringReplace(Result, '零分', '', [rfReplaceAll]);
Result := StringReplace(Result, '零角', '', [rfReplaceAll]);
end;
Result := StringReplace(Result, '零元', '元', [rfReplaceAll]);
Result := StringReplace(Result, '零拾', '', [rfReplaceAll]);
Result := StringReplace(Result, '零佰', '', [rfReplaceAll]);
Result := StringReplace(Result, '零仟', '', [rfReplaceAll]);
Result := StringReplace(Result, '零万', '万', [rfReplaceAll]);

end;
 

Similar threads

回复
0
查看
663
不得闲
回复
0
查看
852
不得闲
回复
0
查看
506
万一
顶部