水晶报表中将数字金额转换为大写公式

阅读: 评论:0

⽔晶报表中将数字⾦额转换为⼤写公式
版本⼀:这种⾦额⼤写忽略不同进度间的零的显⽰,显⽰效果如:⼆⼗万九百⼀元四⾓整(200901.40)
StringVar x;
StringVar xx :="";
NumberVar z;
NumberVar i;
x := ToText(Sum ({@@AMOUNT}));
x := Replace(x,",","");
x := Replace(x,".","");
z := length(x)-2;
for i := z to -1 step -1do
(
select i
case10 : if(Mid(x,z-i+1,1) <>"0") then xx := Mid(x,z-i+1,1) +"⼗"
case9 : if(Mid(x,z-i+1,1) <>"0") then xx := xx + Mid(x,z-i+1,1) +"亿"else xx := xx +"亿"
case8 : if(Mid(x,z-i+1,1) <>"0") then xx := xx + Mid(x,z-i+1,1) +"仟"
case7 : if(Mid(x,z-i+1,1) <>"0") then xx := xx + Mid(x,z-i+1,1) +"佰"
case6 : if(Mid(x,z-i+1,1) <>"0") then xx := xx + Mid(x,z-i+1,1) +"拾"
case5 : if(Mid(x,z-i+1,1) <>"0") then xx := xx + Mid(x,z-i+1,1) +"万"else xx := xx +"万"
case4 : if(Mid(x,z-i+1,1) <>"0") then xx := xx + Mid(x,z-i+1,1) +"仟"
case3 : if(Mid(x,z-i+1,1) <>"0") then xx := xx + Mid(x,z-i+1,1) +"佰"
case2 : if(Mid(x,z-i+1,1) <>"0") then xx := xx + Mid(x,z-i+1,1) +"拾"
case1 : if(Mid(x,z-i+1,1) <>"0") then xx := xx + Mid(x,z-i+1,1)+"元"
case0 : if(Mid(x,z-i+1,1) <>"0") then xx := xx + Mid(x,z-i+1,1)+"⾓"
case-1 : if(Mid(x,z-i+1,1) <>"0") then xx := xx + Mid(x,z-i+1,1) else xx :=xx+"零"
);
xx := Replace(xx,"1","壹");
xx := Replace(xx,"2","贰");
xx := Replace(xx,"3","叁");
xx := Replace(xx,"4","肆");
xx := Replace(xx,"5","伍");
xx := Replace(xx,"6","陆");
xx := Replace(xx,"7","柒");
xx := Replace(xx,"8","捌");
xx := Replace(xx,"9","玖");
if instr(xx,'元') <=0 then
if instr(xx,'⾓')>0 then
xx:=left(xx,instr(xx,'⾓')-2)+'元'+right(xx,len(xx)-instr(xx,'⾓')+2);
if right(xx,1)='零' then
if instr(xx,'元')>0 then
xx :=left(xx,len(xx)-1)+'整'
知网首页
else
xx :=left(xx,len(xx)-1)+'元整'
else
xx :=xx +"分";
版本⼆:这种⾦额⼤写不同进度间的零的显⽰⼀次,显⽰效果如:⼆⼗万零九百零⼀元四⾓整(200901.40)
StringVar x;
StringVar xx:="";
NumberVar z;
NumberVar i;
x := ToText(Sum ({BuyCompact.SC_SumPrice}));
x := Replace(x,",","");
x := Replace(x,".","");
z := length(x);
for i := z to 1 step -1do
(
StringVar temp:=Mid(x,z-i+1,1);
select i
case12 : xx := temp +"⼗"
case11 : xx := xx + temp +"亿"
case10 : xx := xx + temp +"仟"
case9 : xx := xx + temp +"佰"弹幕先审后播
case8 : xx := xx + temp +"拾"
case7 : xx := xx + temp +"万"
case6 : xx := xx + temp +"仟"
case5 : xx := xx + temp +"佰"
case4 : xx := xx + temp +"拾"
case3 : xx := xx + temp +"元"
case2 : xx := xx + temp +"⾓"
case1 : xx := xx + temp +"分"
);
stringvar test="";
z := length(xx);
i:=1;
while i<z do
(
StringVar temp:=Mid(xx,i,1);
if temp="0" then
(
if mid(xx,i-2,1)<>"0" and (Mid(xx,i+1,1)="亿" or Mid(xx,i+1,1)="万" or Mid(xx,i+1,1)="元") then        (
xx :=Left (xx,i-1 )+Replace(xx,Mid(xx,i,1) ,"" ,i , 1);
)
elseif mid(xx,i-2,1)<>"0" and i+2<length(xx) and mid(xx,i+2,1)<>"0" then
(
xx :=Left (xx,i )+Replace(xx,Mid(xx,i+1,1) ,"" ,i+1 , 1);
)
elseif Mid(xx,i+1,1)="⾓" and Mid(xx,i+2,1)<>"0" then
(
xx :=Left (xx,i )+Replace(xx,Mid(xx,i+1,1) ,"" ,i+1 , 1);
)
else
(
i := i-1;
xx :=Left (xx,i )+Replace(xx,Mid(xx,i+1,2) ,"" ,i+1 , 1);
)
);
空气轴承
i:=i+1;
z:=length(xx);
);
xx := Replace(xx,"0","零");
xx := Replace(xx,"0","零");
xx := Replace(xx,"1","壹");
xx := Replace(xx,"2","贰");
xx := Replace(xx,"3","叁");
xx := Replace(xx,"4","肆");
xx := Replace(xx,"5","伍");
xx := Replace(xx,"6","陆");
xx := Replace(xx,"7","柒");
xx := Replace(xx,"8","捌");
xx := Replace(xx,"9","玖");
xx := xx +"整"+test;
界⾯代码:
///<summary>
/// ⼤写显⽰⾦额
///</summary>
///<param name="value">值</param>
publicvoid UpperAccount(decimal value)
{
if (value ==0)
return;
string strValue = value.ToString();
if (!strValue.Contains("."))
{
strValue +=".00";
}
string strResult =string.Empty;
int z, i;
strValue = strValue.Replace(".", "");
z = strValue.Length;
for (i = z; i >=1; i--)
{
string temp = strValue.Substring(z - i, 1);
switch (i)
{
case12: strResult += temp +"拾"; break;
case11: strResult += temp +"亿"; break;
case10: strResult += temp +"仟"; break;
case9: strResult += temp +"佰"; break;
case8: strResult += temp +"拾"; break;
case7: strResult += temp +"万"; break;
case6: strResult += temp +"仟"; break;
case5: strResult += temp +"佰"; break;
case4: strResult += temp +"拾"; break;
case3: strResult += temp +"元"; break;
case2: strResult += temp +"⾓"; break;
case1: strResult += temp +"分"; break;
}
}
z = strResult.Length;
while (i < z)
{
string temp = strResult.Substring(i, 1);
if (temp =="0"&& i ==0)
{
i++;
continue;
}
elseif (temp =="0")
改变自己与改变世界{
if (strResult.Substring(i -2, 1) !="0"&& (strResult.Substring(i +1, 1) =="亿"||
strResult.Substring(i +1, 1) =="万"|| strResult.Substring(i +1, 1) =="元"))
{
strResult = strResult.Remove(i, 1);
}
elseif (strResult.Substring(i -2, 1) !="0"&& i +2< strResult.Length && strResult.Substring(i +2, 1) !="0")
{
strResult = strResult.Remove(i +1, 1);
}
elseif (strResult.Substring(i +1, 1) =="⾓"&& strResult.Substring(i +2, 1) !="0")
{
strResult = strResult.Remove(i +1, 1);
}
else
{
i--;
strResult = strResult.Remove(i +1, 2);
}
}
i++;
z = strResult.Length;
}
strResult = strResult.Replace("0", "零");
strResult = strResult.Replace("1", "壹");
我们都来讲笑话
strResult = strResult.Replace("2", "贰");
strResult = strResult.Replace("3", "叁");
strResult = strResult.Replace("4", "肆");
strResult = strResult.Replace("5", "伍");
strResult = strResult.Replace("6", "陆");
strResult = strResult.Replace("7", "柒");
strResult = strResult.Replace("8", "捌");领导者的影响力
strResult = strResult.Replace("9", "玖");
lblAccount.Text = strResult +"整";
}

本文发布于:2023-07-05 17:42:14,感谢您对本站的认可!

本文链接:https://patent.en369.cn/xueshu/174453.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:转换   改变   数字   中将   弹幕   笑话   领导者
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 369专利查询检索平台 豫ICP备2021025688号-20 网站地图