Recently I found a good source code and posted it for myself and everyone to learn.
// Conversion Program
Public static void floattransform (string strnum, ref string result)
{
String strint;
String strfloat;
Strint = strnum. substring (0, strnum. indexof (".", 0); // integer value
Strfloat = strnum. substring (strnum. indexof (". ", 0) + 1), (strnum. length-strNum.IndexOf (". ", 0)-1); // The value of the fractional part.
// MessageBox. Show (strint );
// MessageBox. Show (strfloat );
// Return;
Int numlen = strint. length;
String dx = "";
String Ws = "yuanqibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaiyi ";
// MessageBox. Show (WS. length. tostring ());
Result = NULL;
Int I = 0, W = 0;
Int q = 0;
Bool Ling = true;
// Calculate the integer in uppercase!
While (I <numlen)
{
If (strint. substring (I, 1 )! = "0 ")
{
// MessageBox. Show (strnum. substring (I, 1 ));
Result = Result + dx. substring (convert. toint32 (strint. substring (I, 1), 1 );
Result = Result + WS. substring (numlen-I) + 1, 1 );
Ling = false;
I ++;
}
Else if (Ling = false & strint. substring (I, 1) = "0 ")
{
If (numlen-I + 1)> 10) // you can determine if the number is over million.
{
W = 0;
For (q = 11; q <(numlen-I + 1); q ++)
{
W = W + convert. toint32 (strint. substring (numlen-q + 1,1 ));
}
If (W = 0)
{
Result = Result + "";
I = numLen-9;
}
Else
{
Result = Result + "zero ";
I = I + 1;
Ling = true;
}
}
Else if (numlen-I + 1)> 6) // you can check whether the value is more.
{
W = 0;
For (q = 1; q <(numlen-I + 1); q ++)
{
W = W + convert. toint32 (strint. substring (numlen-Q, 1 ));
}
If (W = 0)
{
Result = Result + "integer ";
I = numlen + 1;
}
Else
{
Result = Result + "zero ";
I = I + 1;
Ling = true;
}
}
Else if (numlen-I + 1)> 3)
{
W = 0;
For (q = 1; q <(numlen-I + 1); q ++)
{
W = W + convert. toint32 (strint. substring (numlen-Q, 1 ));
}
If (W = 0)
{
Result = Result + "integer ";
I = numlen + 1;
}
Else
{
Result = Result + "zero ";
I = I + 1;
Ling = true;
}
}
Else if (numlen-I + 1)> 0)
{
W = 0;
For (q = 1; q <(numlen-I + 1); q ++)
{
W = W + convert. toint32 (strint. substring (numlen-Q, 1 ));
}
If (W = 0)
{
Result = Result + "integer ";
I = numlen + 1;
}
Else
{
Result = Result + "zero ";
I = I + 1;
Ling = true;
}
}
}
Else if (strint. substring (I, 1) = "0" & Ling = true)
{
I = I + 1;
}
}
// Calculate the decimal part in uppercase!
Int numlenflt = strfloat. length;
If (strfloat. substring (0, 1) = "0" & strfloat. substring (1, 1) = "0 ")
{
Result = Result + "integer ";
}
Else if (strfloat. substring (0, 1 )! = "0" & strfloat. substring (1,1) = "0 ")
{
Result = Result + dx. substring (convert. toint32 (strfloat. substring (0, 1), 1) + "";
}
Else if (strfloat. substring (0, 1) = "0" & strfloat. substring (1, 1 )! = "0 ")
{
Result = Result + dx. substring (convert. toint32 (strfloat. substring (), 1) + "Minute ";
}
Else if (strfloat. substring (0, 1 )! = "0" & strfloat. substring (1, 1 )! = "0 ")
{
Result = Result + dx. substring (convert. toint32 (strfloat. substring (0, 1), 1) + "" + dx. substring (convert. toint32 (strfloat. substring (), 1) + "Minute ";
}
}