Source code for converting numbers to uppercase amounts in the Crystal Report

Source: Internet
Author: User

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 ";
}
 
}

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.