数字转中文大写
1 static str Num2ChnStr(real realNum) 2 { 3 real y; 4 int b, a; 5 str je, x, hz1, hz2, e, h, f, m; 6 boolean IsNegative=false; 7 ; 8 if (realNum == 0) 9 return '零圆'; 10 if (realNum < 0) 11 { 12 realNum = abs(realNum); 13 IsNegative = true; 14 } 15 16 y = realNum; 17 x = strLtrim(strRtrim(num2str(y, 20, 2, 1, 0))); 18 b = strLen(x) - 3; 19 a = 1; 20 e = substr(x, a, 1); 21 hz2 = '零壹贰叁肆伍陆柒捌玖'; 22 hz1 = '仟佰拾亿仟佰拾万仟佰拾圆'; 23 je = ''; 24 while (e != '.') 25 { 26 h = subStr(hz2, str2num(e) * 2 + 1, 2); 27 f = subStr(hz1, 24 - (b - a) * 2 - 1, 2); 28 if (e != '0' || (e == '0' && (f == '亿' || f == '万' || f == '圆'))) 29 je = strLtrim(strRtrim(je)) + h + f; 30 else 31 je = strLtrim(strRtrim(je)) + h; 32 a = a + 1; 33 e = subStr(x, a, 1); 34 } 35 a = a + 1; 36 e = subStr(x, a, 1); 37 h = subStr(x, a + 1, 1); 38 if (e == '0' && h == '0') 39 je = je + '整'; 40 else 41 { 42 if (e == '0') 43 je = je + '零' + subStr(hz2, str2num(h) * 2 + 1, 2) + '分'; 44 else if (h == '0') 45 je = je + substr(hz2, str2num(e) * 2 + 1, 2) + '角整'; 46 else 47 je = je + substr(hz2, str2num(e) * 2 + 1, 2) + '角' + subStr(hz2, str2num(h) * 2 + 1, 2) + '分'; 48 } 49 b = strLen(je); 50 a = 1; 51 while (a < b) 52 { 53 m = substr(je, a, 4); 54 if (m == '零圆' || m == '零万' || m == '零亿' || m == '零零') 55 { 56 je =subStr(je, 1, a - 1) + strLtrim(strRtrim(substr(je, a + 2, 40))); 57 a = a - 2; 58 b = b - 2; 59 } 60 a = a + 2; 61 } 62 63 if (subStr(je, 1, 2) == '圆' && strLen(je) > 2) 64 je = subStr(je, 3, strLen(je) - 2); 65 if (IsNegative) 66 je = '负' + je; 67 return je; 68 }
amount in words(大写金额)
在AX5.0中,在Global中对应转换的方法。如:numeralsToTxt_EN()。