Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Highlighted
Developer
Posts: 134
Registered: ‎08-03-2011
My Device: torch, Z10
My Carrier: Vodafone, Airtel
Accepted Solution

How to get a decimal value from an international currency string

Hi All,

How to get decimal values from an international currency string.

-----------------------------------------------------------------------
"Like" if you liked the post.
"Accept as Solution" if the post solves your question.
-----------------------------------------------------------------------
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: How to get a decimal value from an international currency string

Don't be afraid to put more information, you never know it might help.

 

Are you trying to do this in C++, QML or JavaScript?

 

Each has their own string manipulation functions.

 


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 134
Registered: ‎08-03-2011
My Device: torch, Z10
My Carrier: Vodafone, Airtel

Re: How to get a decimal value from an international currency string

I m trying this using QML.

-----------------------------------------------------------------------
"Like" if you liked the post.
"Accept as Solution" if the post solves your question.
-----------------------------------------------------------------------
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: How to get a decimal value from an international currency string

Okay I may have misunderstood the question are you just trying to get a string value as a number value?


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: How to get a decimal value from an international currency string

[ Edited ]

Try parseInt (e.g. parseInt(textInput1.text))...

 

http://www.w3schools.com/jsref/jsref_parseint.asp

 

You'll see from the link that if the string you have contains initial letter or symbols then you will need to strip them out using the javascript string manipulation routines...

 

http://www.w3schools.com/jsref/jsref_obj_string.asp


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 134
Registered: ‎08-03-2011
My Device: torch, Z10
My Carrier: Vodafone, Airtel

Re: How to get a decimal value from an international currency string

Hello,

I want to get Decimal Separator according to different currency.
-----------------------------------------------------------------------
"Like" if you liked the post.
"Accept as Solution" if the post solves your question.
-----------------------------------------------------------------------
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: How to get a decimal value from an international currency string

[ Edited ]

Okay so I didn't misunderstand, can you post an example of the string and what you want the result to look like.

 

Did you look at the string functions, where you not able to work out what you needed from them?

 

[Edit] Seriously mate, the more information you put here the more likely you are to get an answer that solves your problem and doesn't waste people's time guessing what it is you want!

 


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 134
Registered: ‎08-03-2011
My Device: torch, Z10
My Carrier: Vodafone, Airtel

Re: How to get a decimal value from an international currency string


currency is formatted with a decimal point (.) as a separator between the dollars and cents. Some countries use a comma (,) instead of a decimal to indicate that separation.

http://www.dfa.cornell.edu/treasurer/cashoperations/cashmanagement/internationalfunds/conversion.cfm

How to get which decimal seprator is used for selected language.
-----------------------------------------------------------------------
"Like" if you liked the post.
"Accept as Solution" if the post solves your question.
-----------------------------------------------------------------------
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: How to get a decimal value from an international currency string

Finally we get to the actual problem. Smiley Happy

 

You can either use the localisation functions or write your own using the string functions mentioned earlier...

 

http://developer.blackberry.com/native/documentation/cascades/device_platform/internationalization/


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.