StringVar x;
StringVar xx := "";
NumberVar z;
NumberVar i;
x := ToText({CL_CFKB.FKJE});
x := Left(x,length(x)-5); //这里所减去的数字,是小数点后面的位数加1的值
//我这里是存储时保留小数点后4 位,所以只能精确到个位。
x := Replace(x,",","");
z := length(x);
for i := z to 1 step -1 do
(
select i
case 8 : if(Mid(x,z-i+1,1)<>"0") then xx := Mid(x,z-i+1,1) + "十"
case 7 : if(Mid(x,z-i+1,1)<>"0") then xx := xx + Mid(x,z-i+1,1) + "亿" else xx := xx + "亿"
case 6 : if(Mid(x,z-i+1,1)<>"0") then xx := xx + Mid(x,z-i+1,1) + "仟"
case 5 : if(Mid(x,z-i+1,1)<>"0") then xx := xx + Mid(x,z-i+1,1) + "佰"
case 4 : if(Mid(x,z-i+1,1)<>"0") then xx := xx + Mid(x,z-i+1,1) + "十"
case 3 : if(Mid(x,z-i+1,1)<>"0") then xx := xx + Mid(x,z-i+1,1) + "万" else xx := xx + "万"
case 2 : 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) + "佰"
);
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 + "元整";
StringVar xx := "";
NumberVar z;
NumberVar i;
x := ToText({CL_CFKB.FKJE});
x := Left(x,length(x)-5); //这里所减去的数字,是小数点后面的位数加1的值
//我这里是存储时保留小数点后4 位,所以只能精确到个位。
x := Replace(x,",","");
z := length(x);
for i := z to 1 step -1 do
(
select i
case 8 : if(Mid(x,z-i+1,1)<>"0") then xx := Mid(x,z-i+1,1) + "十"
case 7 : if(Mid(x,z-i+1,1)<>"0") then xx := xx + Mid(x,z-i+1,1) + "亿" else xx := xx + "亿"
case 6 : if(Mid(x,z-i+1,1)<>"0") then xx := xx + Mid(x,z-i+1,1) + "仟"
case 5 : if(Mid(x,z-i+1,1)<>"0") then xx := xx + Mid(x,z-i+1,1) + "佰"
case 4 : if(Mid(x,z-i+1,1)<>"0") then xx := xx + Mid(x,z-i+1,1) + "十"
case 3 : if(Mid(x,z-i+1,1)<>"0") then xx := xx + Mid(x,z-i+1,1) + "万" else xx := xx + "万"
case 2 : 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) + "佰"
);
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 + "元整";

博客展示了一段代码,对数字进行存储处理。先将数字转换为文本,截取到个位,去除逗号,再通过循环根据数字位数添加单位,最后将数字替换为中文大写,最终输出带“元整”的结果,涉及数字存储和格式转换。
2491

被折叠的 条评论
为什么被折叠?



