Convert numeric amount into large write amount dll

Source: Internet
Author: User

Public class MoneyConvertChinese
{
/// <Summary>
/// Convert the amount to uppercase
/// </Summary>
/// <Param name = "LowerMoney"> amount to be converted </param>
/// <Returns> capital amount </returns>
Public string MoneyToChinese (string LowerMoney)
{
String functionReturnValue = null;
Bool IsNegative = false; // whether it is a negative number
If (LowerMoney. Trim (). Substring (0, 1) = "-")
{
LowerMoney = LowerMoney. Trim (). Remove (0, 1 );
IsNegative = true;
}
Try
{
String strLower = null;
String strUPart = null;
String strUpper = null;
Int iTemp = 0;
LowerMoney = Math. Round (double. Parse (LowerMoney), 2). ToString ();
// Keep it to two decimal places
If (LowerMoney. IndexOf (".")> 0)
{
If (LowerMoney. IndexOf (".") = LowerMoney. Length-2)
{
LowerMoney = LowerMoney + "0 ";
}
}
Else
{
LowerMoney = LowerMoney + ". 00 ";
}
StrLower = LowerMoney;

ITemp = 1;
StrUpper = "";
While (iTemp <= strLower. Length)
{
Switch (strLower. Substring (strLower. Length-iTemp, 1 ))
{
Case ".":
StrUPart = "circle ";
Break;
Case "0 ":
StrUPart = "zero ";
Break;
Case "1 ":
StrUPart = "1 ";
Break;
Case "2 ":
StrUPart = "II ";
Break;
Case "3 ":
StrUPart = "";
Break;
Case "4 ":
StrUPart = "Si ";
Break;
Case "5 ":
StrUPart = "Wu ";
Break;
Case "6 ":
StrUPart = "";
Break;
Case "7 ":
StrUPart = "parts ";
Break;
Case "8 ":
StrUPart = "parts ";
Break;
Case "9 ":
StrUPart = "parts ";
Break;
}
Switch (iTemp)
{
Case 1:
StrUPart = strUPart + "points ";
Break;
Case 2:
StrUPart = strUPart + "";
Break;
Case 3:
StrUPart = strUPart + "";
Break;
Case 4:
StrUPart = strUPart + "";
Break;
Case 5:
StrUPart = strUPart + "pick up ";
Break;
Case 6:
StrUPart = strUPart + "parts ";
Break;
Case 7:
StrUPart = strUPart + "parts ";
Break;
Case 8:
StrUPart = strUPart + "Ten Thousand ";
Break;
Case 9:
StrUPart = strUPart + "pick up ";
Break;
Case 10:
StrUPart = strUPart + "parts ";
Break;
Case 11:
StrUPart = strUPart + "parts ";
Break;
Case 12:
StrUPart = strUPart + "";
Break;
Case 13:
StrUPart = strUPart + "pick up ";
Break;
Case 14:
StrUPart = strUPart + "parts ";
Break;
Case 15:
StrUPart = strUPart + "parts ";
Break;
Case 16:
StrUPart = strUPart + "Ten Thousand ";
Break;
Default:
StrUPart = strUPart + "";
Break;
}
StrUpper = strUPart + strUpper;
ITemp = iTemp + 1;
}

StrUpper = strUpper. Replace ("Zero pick", "zero ");
StrUpper = strUpper. Replace ("zero percent", "zero ");
StrUpper = strUpper. Replace ("zero percent", "zero ");
StrUpper = strUpper. Replace ("zero", "zero ");
StrUpper = strUpper. Replace ("zero", "zero ");
StrUpper = strUpper. Replace ("zero-angle zero-point", "whole ");
StrUpper = strUpper. Replace ("0 points", "whole ");
StrUpper = strUpper. Replace ("", "");
StrUpper = strUpper. Replace ("0 billion 0 thousand ");
StrUpper = strUpper. Replace ("0 thousand ");
StrUpper = strUpper. Replace ("0 billion 0 thousand", "");
StrUpper = strUpper. Replace ("0 thousand ");
StrUpper = strUpper. Replace ("", "");
StrUpper = strUpper. Replace ("0 billion ");
StrUpper = strUpper. Replace ("0 thousand ");
StrUpper = strUpper. Replace ("0 circle", "circle ");
StrUpper = strUpper. Replace ("zero", "zero ");
// Processing the amount below the yundun
If (strUpper. Substring (0, 1) = "circle ")
{
StrUpper = strUpper. Substring (1, strUpper. Length-1 );
}

If (strUpper. Substring (0, 1) = "0 ")
{
StrUpper = strUpper. Substring (1, strUpper. Length-1 );
}

If (strUpper. Substring (0, 1) = "")
{
StrUpper = strUpper. Substring (1, strUpper. Length-1 );
}

If (strUpper. Substring (0, 1) = "points ")
{
StrUpper = strUpper. Substring (1, strUpper. Length-1 );
}

If (strUpper. Substring (0, 1) = "integer ")
{
StrUpper = "Zero circle ";
}
FunctionReturnValue = strUpper;
}
Catch
{
FunctionReturnValue = "Zero circle ";
}
If (IsNegative = true)
{
Return "negative" + functionReturnValue;
}
Else
{
Return functionReturnValue;
}
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.