zoukankan      html  css  js  c++  java
  • 数字转中文大写

     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()。

  • 相关阅读:
    vuex
    koa2+node+vue自启服务运行本地脚本
    重新认识js(一)
    JQuery图片左右无缝滚动
    javascript兼容性很好的省市区联动,易修改
    JQuery超级简单的TAB选项卡
    ViewState的原理分析
    JQuery图片切换特效
    asp.net验证控件详解【转】
    时间线 制作
  • 原文地址:https://www.cnblogs.com/Jinnchu/p/2663256.html
Copyright © 2011-2022 走看看