人民幣大小寫金額轉換

2021-07-08 17:20:30 字數 1549 閱讀 7893

1.呼叫    convertinttouppercaseamount(string value)  即可

/// 人民幣大小寫金額轉換

///class

rmbcapitalization

else

if (currchar != 0)

else

if (prevchar != 0 )

else }

}//對結果進行容錯處理

if(capresult.length > 0)}}

capresult = currcap + capresult;

prevchar = currchar;

posindex += 1;

currcap =""; }

return capresult; }

////// 轉換小數為大寫金額

//////

小數值/// 是否增加零位

/// 返回大寫金額

private

string convertdectouppercaseamount(string capvalue,bool addzero)

else

else

if (prevchar != 0)

} capresult += currcap ;

prevchar = currchar;

posindex -= 1;

currcap =""; }

return capresult; }

////// 人民幣大寫金額

//////

人民幣數字金額值

/// 返回人民幣大寫金額

public

string rmbamount(double value)

", value);      //

格式化int dotpos = capvalue.indexof(".");                    //

小數點位置

bool addint = (convert.toint32(capvalue.substring(dotpos+1)) == 0);//

是否在結果中加"整"

bool addminus = (capvalue.substring(0, 1) =="-");     //

是否在結果中加"負"

int beginpos = addminus ? 1 : 0;                       //

開始位置

string capint = capvalue.substring(beginpos, dotpos);  //

整數 string capdec = capvalue.substring(dotpos + 1);        //

小數 if (dotpos > 0)

else

if (addminus) capresult ="

負"+ capresult;

if (addint) capresult +="

整";return capresult; }

}

人民幣金額大小寫轉換

大家在編寫涉及到金額的程式的時候,有時候需要將小寫的人民幣金額轉換成大寫表示 下面的 介紹了轉換的實現過程,大家可以參考一下 pragma warning disable 4786 include include include include using std vector using std ...

人民幣大小寫轉換

using system using system.text using system.text.regularexpressions namespace hkh.common region 格式化 格式化 大寫轉小寫 public static double format string strrm...

人民幣大小寫轉換

using system using system.text using system.text.regularexpressions namespace hkh.common region 格式化 格式化 大寫轉小寫 public static double format string strrm...