Function MaxtoMin(minje:string):string;
var
dx,dy,nn,cccc,dd,c,cc,lc:string;
n,iii:integer;
begin
dx:='壹贰叁肆伍陆柒捌玖';
dy:='分角圆拾佰仟万拾佰仟亿拾佰';
nn:=trim(floattostr(strtofloat(minje)*100));
n:=length(nn);
cccc:='整';
for iii:=1 to n do
begin
dd:=copy(dy,iii*2-1,2);
c:=copy(nn,n-iii+1,1);
if c<>'0' then
begin
cc:=copy(dx,(strtoint(c)*2 - 1),2);
cccc:=trim(cc)+trim(dd)+trim(cccc);
end
else
begin
lc:=copy(trim(cccc),1,2);
if ((iii=3) or (iii=7) or (iii=11)) then
begin
cccc:=trim(dd) + trim(cccc);
continue;
end;
if ((lc<>'零') and (LC<>'整') and (LC<>'亿') and (LC<>'万') and (LC<>'圆')) then
cccc:='零'+cccc;
end;
end;
cccc:='合计:'+cccc;
Result:=cccc;
/////////////////
Function UPCaseMoney(Value: String): String;
//字符串转换成实数
Function StrToSingle(const Value: String): Currency;
var
St,Data: String;
i: Integer;
begin
Data := Value;
if Pos('.',Data) = 1 then//如果是以.开头
Data := '0' + Data;
if Pos('.',Data) <= 0 then//没有.
Data := Data + '.00';
St := Copy(Data,0,Pos('.',Data) - 1);//截取整数部分
i := StrToInt(St);
Result := i;
St := Copy (Data,Pos('.',Data) + 1,2);//取小数部分
if Length(St) < 2 then//长度不足
St := St + '0';
i := StrToInt(St);
Result := Result + (i/100);
end;
const
Money: Array[0..15] of String = ('零', '壹', '贰', '参', '肆',
'伍', '陆', '柒', '捌', '玖',
'', '拾', '佰', '仟', '万', '亿'
);
ConMoney: Array[0..2] of String = ('元', '角', '分');
var
Str, Str1, St,
IMon, //整数部分
FMon: String; //小数部分
Zero: Boolean; //是否有零
i, kk: Integer;
Function StrToMoney(const Value: String; const Fen: Bool = False): String;
var
j: Integer;
begin
Result := '';
for j := 1 to Length(Value) do
begin
if Value[j] = '0' then
begin
Zero := True;
Continue;
end;
if Zero then
begin
Zero := False;
Result := Result + Money[0];
end;
Result := Result + Money[StrToInt(Value[j])];
if Fen then
Result := Result + ConMoney[j]
else
Result := Result + Money[10 + Length(Value) - j];
end;
end;
begin
Str := Format('%2f', [StrToSingle(Value)]);
Result := '零元整';
if Str = '0.00' then
Exit;
Result := '';
i := Pos('.', Str);
IMon := Copy(Str, 0, i - 1);
FMon := Copy(Str, i + 1, 2);
Zero := False;
for i := 0 to Length(IMon) DIV 9 + 1 do
begin
kk := ABS(Length(IMon) - (Length(IMon) DIV 9) * 9 + 1);
Str1 := Copy(IMon, 0, kk);
IMon := Copy(IMon, kk + 1, Length(IMon) - kk);
if Length(Str1) <= 0 then
Continue;
if Length(Str1) > 4 then
begin
Str := Copy(Str1, 0, Length(Str1) - 4);
Str1 := Copy(Str1, Length(Str1) - 3, 4);
St := StrToMoney(Str);
if St <> '' then
Result := Result + St + Money[14];
end;
Result := Result + StrToMoney(Str1);
if Length(IMon) > 0 then
Result := Result + Money[15];
end;
Result := Result + ConMoney[0];
Zero := False;
//Result := Result + StrToMoney(FMon, True) + '整'; //最后一行改成
St := StrToMoney(FMon, True);
if St <> '' then
if Pos(Money[0], St) <= 0 then
Result := Result + Money[0] + St
else
// Result := Result + St;
Result := Result
else
Result := Result + '整'
end;
function CovMoney(const money: Double): widestring; //小写金额转换成大写金额
const cN:WideString='零壹贰叁肆伍陆柒捌玖-万仟佰拾亿仟佰拾万仟佰拾元角分';
cCha:array[0..1, 0..11]of string =
(( '零仟','零佰','零拾','零零零','零零','零亿','零万','零元','亿万','零角','零分','零整'),
( '零','零','零','零','零','亿','万','元','亿','零','整','整'));
var i :Integer;
sNum :WideString;
begin
result := '';
sNum := FormatFloat('0',money*100);
for i := 1 to Length(sNum) do
result := result + cN[ord(sNum[i])-47] + cN[26-Length(sNum)+i];
for i:= 0 to 11 do //去掉多余的零
result := StringReplace(result, cCha[0,i], cCha[1,i], [rfReplaceAll]);
end;
uses
Windows, SysUtils, Forms;
const CapsDigi: array[0..9] of string = ('零','壹','贰','叁','肆','伍','陆','柒','捌','玖');
CapsUnit: array[0..10] of string = ('分','角','元','拾','佰','仟','万','拾','佰','仟','亿');
function CapsMoney(money:string):string;
implementation
function CapsMoney(money:string):string;
var
Temp: string;
s,s1: string;
i: integer;
l: integer;
begin
Temp := '';
s := '';
s1 := '';
try
s := FormatCurr('0.00',StrToCurr(money));
for i:= 1 to Length(s) do
if s[i] <> '.' then
s1 := s1 + s[i];
l:= Length(s1);
for i:= 1 to l do
begin
if (s1[i] = '0') then
begin
if s1[i + 1] = '0' then Temp := Temp;
if ((l - i = 2) or (l - i = 6)) then
Temp := Temp + CapsUnit[l - i];
if ((s1[i + 1] <> '0') and (i<>l)) then
Temp := Temp + CapsDigi[StrToInt(s1[i])];
if i = l then Temp := Temp + '整';
end
else
Temp := Temp + CapsDigi[StrToInt(s1[i])] + CapsUnit[Length(s1) - i];
end;
except
Application.MessageBox('数据转换错误,请重来!','错误',MB_OK + MB_ICONERROR);
end;
Result := Temp;
end;
金额大小写转换
function My_StrToRMB(curs :string) :string;
implementation
function My_StrToRMB(curs: string) :string ;
var
daxie,danwei,minuscurs:string;
i,j,deccount :integer ;
rmb :int64;
begin
curs:=trim(curs);
if (curs='-') or (curs='.') or (curs='') then // '.','-',''错
begin
result:='ERROR';
exit;
end;
deccount :=0;
for i:=1 to length(curs) do
begin
if not (curs[i] in ['0'..'9','.','-']) then //'123w2'错
begin
result:='ERROR';
exit;
end;
if (curs[i]='.') and (deccount>0) then //'12313.324.23'错
begin
result:='ERROR';
exit;
end;
if (curs[i]='-') and (i>1) then //'-123-123'错
begin
result:='ERROR';
exit;
end;
if curs[i]='.' then inc(deccount);
end;
rmb:=round(StrToFloat(curs)*100);
minuscurs:=''; //负数标志
if rmb<0 then
begin
minuscurs:='(负数)' ;
rmb:=(-1)*rmb;
end;
if rmb>=1E18 then //超过9千万亿
begin
result:='ERROR';
exit;
end;
curs:='';
i:=0; j:=0 ;
while rmb>0 do
begin
j:= rmb mod 10;
case j of
0 : daxie :='零' ;
1 : daxie :='壹' ;
2 : daxie :='贰' ;
3 : daxie :='叁' ;
4 : daxie :='肆' ;
5 : daxie :='伍' ;
6 : daxie :='陆' ;
7 : daxie :='柒' ;
8 : daxie :='捌' ;
9 : daxie :='玖' ;
end;
case i of
0 : danwei :='分' ;
1 : danwei :='角' ;
2 : danwei :='圆' ;
3 : danwei :='拾' ;
4 : danwei :='佰' ;
5 : danwei :='仟' ;
6 : danwei :='万' ;
7 : danwei :='拾' ;
8 : danwei :='佰' ;
9 : danwei :='仟' ;
10 : danwei :='亿' ;
11 : danwei :='拾' ;
12 : danwei :='佰' ;
13 : danwei :='仟' ;
14 : danwei :='万' ;
15 : danwei :='拾' ;
16 : danwei :='佰' ;
17 : danwei :='仟' ;
end;
rmb:=rmb div 10;
if j<>0 then curs:=daxie+danwei+curs; //该位上不为0
if (j=0) and (not (i in [2,6,10,14])) then //该位为0,是一般位
curs:=daxie+curs;
if (j=0) and (i in [2,6,10,14]) then //该位为0,是敏感位
curs:=danwei+curs;
inc(i);
end;
while pos('零零',curs)>0 do curs:=stringreplace(curs,'零零','零',[]);
curs:=stringreplace(curs,'零圆','圆',[]);
while pos('零万',curs)>0 do curs:=stringreplace(curs,'零万','万',[]); //上万亿后可能两个'零万'
curs:=stringreplace(curs,'零亿','亿',[]);
curs:=stringreplace(curs,'角零','角整',[]);
if copy(curs,length(curs)-3,4)='圆零' then //最后两位是圆零.
curs:=stringreplace(curs,'圆零','圆整',[]); //小数点后
curs:=stringreplace(curs,'亿万','亿',[]);
result:=minuscurs+curs;
end;
怎么乱码了??重发一个。
function ChinaTotal(Aje:Double):string;
var
s_1,s_2:widestring;
s_5:char;
s_4:string;
i:integer;
mm:string;
s_6,s_7:widestring;
begin
s_4:=Format('%10d',[Trunc(aje*100)]);
s_1:='零壹贰叁肆误陆柒捌玖';
s_2:='仟佰拾万仟佰拾元角分';
i:=1;
mm:='';
while i<=10 do
begin
s_5:=s_4[i];
if s_5<>' ' then
begin
s_6:=s_1[ord(s_5)-ORD('0')+1];
s_7:=s_2[i];
if (s_5='0') and (i<>4) and (i<>8) then
s_7:='';
if (copy(s_4,i,2)='00') or ( (s_5='0') and (i in [4,8,10])) then
s_6:='';
mm:=mm+s_6+s_7;
if (s_4[i]='0') and ((s_4[i+1]<>'0') and (i in [4,8])) then
mm:=mm+s_1[1];
end;
inc(i);
end ;
if s_5='0' then mm:=mm+'整';
result:=mm;
end;
function ChinaTotal(Aje:Double):string;
var
s_1,s_2:widestring;
s_5:char;
s_4:string;
i:integer;
mm:string;
s_6,s_7:widestring;
begin
s_4:=Format('%10d',[Trunc(aje*100)]);
s_1:='ÁãÒ¼·¡ÈþËÁÎé½Æâ°Æ¾Á';
s_2:='Ǫ°ÛʰÍòǪ°ÛʰԪ½Ç·Ö';
i:=1;
mm:='';
while i<=10 do
begin
s_5:=s_4[i];
if s_5<>' ' then
begin
s_6:=s_1[ord(s_5)-ORD('0')+1];
s_7:=s_2[i];
if (s_5='0') and (i<>4) and (i<>8) then
s_7:='';
if (copy(s_4,i,2)='00') or ( (s_5='0') and (i in [4,8,10])) then
s_6:='';
mm:=mm+s_6+s_7;
if (s_4[i]='0') and ((s_4[i+1]<>'0') and (i in [4,8])) then
mm:=mm+s_1[1];
end;
inc(i);
end ;
if s_5='0' then mm:=mm+'Õû';
result:=mm;
end;