金额大写转换函数
1
//------------------转大写金额函数--------------------------------------------
2
function NumToChnStr(Value: Real): String;
3
const
4
ChnUnit: array[0..13] of string = ('分', '角', '元', '拾', '佰', '仟', '万', '拾', '佰', '仟', '亿', '拾', '佰', '仟');
5
ChnNum : array[0..9] of string = ('零', '壹','贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖');
6
var
7
I: Integer;
8
StrValue, StrNum: String;
9
ValueLen: Integer;
10
begin
11
try
12
13
StrValue := IntToStr(Round(Value * 100));
14
ValueLen := Length(StrValue);
15
Result := '';
16
for I := 1 to ValueLen do
17
begin
18
StrNum := StrValue[I];
19
Result := Result + ChnNum[StrToInt(StrNum)] + ChnUnit[ValueLen - I];
20
end;
21
Result := StringReplace(Result, '零角', '', [rfReplaceAll]);
22
Result := StringReplace(Result, '零分', '', [rfReplaceAll]);
23
Result := StringReplace(Result, '零拾', '零', [rfReplaceAll]);
24
Result := StringReplace(Result, '零佰', '零', [rfReplaceAll]);
25
Result := StringReplace(Result, '零仟', '零', [rfReplaceAll]);
26
Result := StringReplace(Result, '零万', '万', [rfReplaceAll]);
27
//Result := StringReplace(Result, '零元', '元', [rfReplaceAll]);
28
while pos('零零',Result)<>0 do
29
Result := StringReplace(Result, '零零', '零', [rfReplaceAll]);
30
if pos('零元',Result)<>0 then
31
Result := StringReplace(Result, '零元', '元', [rfReplaceAll]);
32
if pos('分',Result)=0 then
33
Result := Result+'整';
34
if (pos('分',Result)<>0) and (pos('角',Result)=0) then
35
Result := StringReplace(Result, '元', '元零', [rfReplaceAll]);
36
except
37
MessageDlg('转换出错!',mtInformation,[mbOK],0);
38
exit;
39
end;
40
end;
//------------------转大写金额函数--------------------------------------------2
function NumToChnStr(Value: Real): String;3
const4
ChnUnit: array[0..13] of string = ('分', '角', '元', '拾', '佰', '仟', '万', '拾', '佰', '仟', '亿', '拾', '佰', '仟');5
ChnNum : array[0..9] of string = ('零', '壹','贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖');6
var7
I: Integer;8
StrValue, StrNum: String;9
ValueLen: Integer;10
begin11
try12

13
StrValue := IntToStr(Round(Value * 100));14
ValueLen := Length(StrValue);15
Result := '';16
for I := 1 to ValueLen do17
begin18
StrNum := StrValue[I];19
Result := Result + ChnNum[StrToInt(StrNum)] + ChnUnit[ValueLen - I];20
end;21
Result := StringReplace(Result, '零角', '', [rfReplaceAll]);22
Result := StringReplace(Result, '零分', '', [rfReplaceAll]);23
Result := StringReplace(Result, '零拾', '零', [rfReplaceAll]);24
Result := StringReplace(Result, '零佰', '零', [rfReplaceAll]);25
Result := StringReplace(Result, '零仟', '零', [rfReplaceAll]);26
Result := StringReplace(Result, '零万', '万', [rfReplaceAll]);27
//Result := StringReplace(Result, '零元', '元', [rfReplaceAll]);28
while pos('零零',Result)<>0 do29
Result := StringReplace(Result, '零零', '零', [rfReplaceAll]);30
if pos('零元',Result)<>0 then31
Result := StringReplace(Result, '零元', '元', [rfReplaceAll]);32
if pos('分',Result)=0 then33
Result := Result+'整';34
if (pos('分',Result)<>0) and (pos('角',Result)=0) then35
Result := StringReplace(Result, '元', '元零', [rfReplaceAll]);36
except37
MessageDlg('转换出错!',mtInformation,[mbOK],0);38
exit;39
end;40
end;

浙公网安备 33010602011771号