大众计算机学习网

专门提供各种电脑教程

asp.net将人民币数字转为为对应的大写金额代码下篇

Admin | 2010-1-21 20:41:05 | 被阅次数 | 4540

  接中篇…

        else
        {
            //该位是万亿,亿,万,元位等关键位
            if (str3 != "0" && nzero != 0)
            {
                ch1 = "零" + str1.Substring(temp * 1, 1);
                ch2 = str2.Substring(i, 1);
                nzero = 0;
            }
            else
            {
                if (str3 != "0" && nzero == 0)
                {
                    ch1 = str1.Substring(temp * 1, 1);
                    ch2 = str2.Substring(i, 1);
                    nzero = 0;
                }
                else
                {
                    if (str3 == "0" && nzero >= 3)
                    {
                        ch1 = "";
                        ch2 = "";
                        nzero = nzero + 1;
                    }
                    else
                    {
                        if (j >= 11)
                        {
                            ch1 = "";
                            nzero = nzero + 1;
                        }
                        else
                        {
                            ch1 = "";
                            ch2 = str2.Substring(i, 1);
                            nzero = nzero + 1;
                        }
                    }
                }
            }
        }
        if (i == (j - 11) || i == (j - 3))
        {
            //如果该位是亿位或元位,则必须写上
            ch2 = str2.Substring(i, 1);
        }
        str5 = str5 + ch1 + ch2;
        if (i == j - 1 && str3 == "0")
        {
            //最后一位(分)为0时,加上“整”
            str5 = str5 + '整';
        }
    }
    if (num == 0)
    {
        str5 = "零元整";
    }
    return str5;
}