Protected void page_load (Object sender, eventargs E)
{
Response. Write (loancapital (2596736 ));
Response. End ();
}
Public static string loancapital (decimal num)
{
String str1 = ""; // Chinese characters corresponding to 0-9
String str2 = "tens of thousands of Chinese characters, hundreds of millions of Chinese characters, and tens of thousands of Chinese characters"; // Chinese characters corresponding to digits
String str3 = ""; // value retrieved from the original num Value
String str4 = ""; // string format of a number
String str5 = ""; // the capital amount of RMB
Int I; // cyclic variable
Int J; // multiply the value of num by the string length of 100
String delimiter = ""; // Chinese reading of numbers
String CH2 = ""; // Chinese character reading of digits
Int nzero = 0; // number of consecutive zero values used for calculation
Int temp; // value retrieved from the original num Value
Bool fushu = (Num <0 );
Num = math. Round (math. Abs (Num), 2); // returns the absolute value of num and rounding it to 2 decimal places.
Str4 = (long) (Num * 100). tostring (); // multiply num by 100 and convert it into a string
J = str4.length; // locate the highest bit
If (j> 15) {return "overflow ";}
Str2 = str2.substring (15-j); // retrieve the str2 value of the corresponding number of digits. For example: 200.55, J is 5, so str2 = hour
// Cyclically retrieve the value to be converted for each bit
For (I = 0; I <j; I ++)
{
Str3 = str4.substring (I, 1); // retrieves the value of a certain bit to be converted.
Temp = convert. toint32 (str3); // convert to a number
If (I! = (J-3) & I! = (J-7) & I! = (J-11) & I! = (J-15 ))
{
// When the number of retrieved digits is not RMB, or trillions of digits
If (str3 = "0 ")
{
Operator = "";
CH2 = "";
Nzero = nzero + 1;
}
Else
{
If (str3! = "0" & nzero! = 0)
{
Bytes = "zero" + str1.substring (temp * 1, 1 );
CH2 = str2.substring (I, 1 );
Nzero = 0;
}
Else
{
Dependencies = str1.substring (temp * 1, 1 );
CH2 = str2.substring (I, 1 );
Nzero = 0;
}
}
}
Else
{
// This digit is a key digit of trillions, hundreds of millions, tens of thousands, and Yuan.
If (str3! = "0" & nzero! = 0)
{
Bytes = "zero" + str1.substring (temp * 1, 1 );
CH2 = str2.substring (I, 1 );
Nzero = 0;
}
Else
{
If (str3! = "0" & nzero = 0)
{
Dependencies = str1.substring (temp * 1, 1 );
CH2 = str2.substring (I, 1 );
Nzero = 0;
}
Else
{
If (str3 = "0" & nzero> = 3)
{
Operator = "";
CH2 = "";
Nzero = nzero + 1;
}
Else
{
If (j> 11)
{
Operator = "";
Nzero = nzero + 1;
}
Else
{
Operator = "";
CH2 = str2.substring (I, 1 );
Nzero = nzero + 1;
}
}
}
}
}
If (I = (J-11) | I = (J-3 ))
{
// If this digit is a hundred million or a metadigit, it must be written
CH2 = str2.substring (I, 1 );
}
Str5 = str5 + separator + CH2;
If (I = J-1 & str3 = "0 ")
{
// When the last digit (minute) is 0, add an integer"
Str5 = str5 + 'Integral ';
}
}
If (num = 0)
{
Str5 = "Zero RMB ";
}
If (fushu)
Str5 = string. Format ("negative {0}", str5 );
Return str5;
}