Convert 1000 to int type to 1,000 to international currency standard

Source: Internet
Author: User

Function fun (data: INT): String {
VaR STR: String = string (data );
VaR B: String = new string ();
VaR C: String = new string ();
VaR D: String = new string ()
VaR E: String = new string ()
VaR F: String = new string ()
For (var j: Int = Str. length; j> = 0; j --){
E + = Str. charat (j)
}
For (var I: Int = 0; I <E. length; I + = 3 ){
C + = B. Concat ("," + E. substring (I, I + 3 ));
}
If (C. charat (0) = ","){
D = C. substring (1, C. length)
} Else {
D = C
}
For (var n: Int = D. length; n> = 0; n --){
F + = D. charat (N)
}
Return F;
}
Trace (fun (121312324245 ));

This is the principle and needs to be optimized.

 

 

<? XML version = "1.0" encoding = "UTF-8"?>
<! -- Simple example to demonstrate the currencyformatter. -->
<Mx: Application xmlns: MX = "http://www.adobe.com/2006/mxml">
 
<Mx: SCRIPT>
<! [CDATA [

Import MX. Events. validationresultevent;
Private var vresult: validationresultevent;

// Event handler to validate and format input.
Private function Format (): void {

Vresult = numval. Validate ();

If (vresult. type = validationresultevent. Valid ){
VaR temp: Number = Number (priceus. Text );
Formattedusprice. Text = usdformatter. Format (temp );
}

Else {
Formattedusprice. Text = "";
}
}
]>
</MX: SCRIPT>
 
<Mx: currencyformatter id = "usdformatter" precision = "2"
Currencysymbol = "" decimalseparatorfrom = "."
Decimalseparatorto = "." usenegativesign = "true"
Usethousandsseparator = "true" alignsymbol = "Left"/>
 
<Mx: numbervalidator id = "numval" Source = "{priceus}" property = "text"
Allownegative = "true" Domain = "real"/>
 
<Mx: panel title = "currencyformatter example" width = "75%" Height = "75%"
Paddingtop = "10" paddingleft = "10" paddingright = "10" paddingbottom = "10">

<Mx: Form>
<Mx: formitem label = "enter U. S. dollar amount:">
<Mx: textinput id = "priceus" text = "" width = "50%"/>
</MX: formitem>

<Mx: formitem label = "formatted amount:">
<Mx: textinput id = "formattedusprice" text = "" width = "50%" editable = "false"/>
</MX: formitem>

<Mx: formitem>
<Mx: button label = "Validate and format" Click = "format ();"/>
</MX: formitem>
</MX: Form>

</MX: Panel>
</MX: Application>

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.