IS there any way, using the dataformatstring, to move the Euro (€) currency symbol to the beggining of the value without hardcoding the euro symbol in the xml?
Example : Using {0:C} I get 1234€ and what i want is to get €1234 . I can't find a solution for this without having to hardcode de euro symbol like €{0:g} .
Any clue ?
Regards
You need to set the CurrencyPositivePattern to 0:
NumberFormatInfo nfi = (NumberFormatInfo)NumberFormatInfo.CurrentInfo.Clone();
nfi.CurrencyPositivePattern = 0;
You will likely want to set the CurrencyNegativePattern as well. The link provides all of the patterns.
It would seem safest to specify the default currency symbol.
As whatever your defualt culture is (e.g in case of French Currrency there is a dual currency either it can be the local currency or euros)
NumberFormatInfo numberFormatInfo= (NumberFormatInfo)NumberFormatInfo.CurrentInfo.Clone();
numberFormatInfo.CurrencySymbol = "€";
Related
DEFINE VARIABLE cDateTime AS CHARACTER NO-UNDO.
DEFINE TEMP-TABLE tt_data NO-UNDO
FIELD DateTime AS DECIMAL FORMAT "->>,>>9.99".
ASSIGN
cDateTime = "20191604121566".
CREATE tt_data.
ASSIGN
tt_data.DateTime = DECIMAL(cDateTime) /* Message Date and Time */
But it says:
"Value cannot be displayed using ->>>,>>>,>>9.999999".
Could you please help this case and tell me what is wrong here?
The code that you show does not result in the error that you are reporting.
I'm guessing that you have a DISPLAY statement somewhere in your real code.
The reported error simply means that that DISPLAY format is not wide enough for the data. By default DISPLAY will use whatever format you specified in the definition of a data element. If you did not specify anything then every datatype also has a default. For decimals the default is "->>,>>>.99".
You can either increase the format in the definition or override it in the display statement like so:
display tt_data.DateTime format ">>>>>>>>>>>>>>>9".
Note: the display format has no influence on the values that you can store in a field. You can always "overstuff" more data into a variable than you can display. The format is only for output display purposes -- it has nothing to do with storage.
The assignment works fine, however the display not.
So ...
DISPLAY tt_data.DateTime.
... does not work because it uses format "->>,>>9.99".
You can change the format in the definition, for example "99999999999999", or do:
DISPLAY tt_data.DateTime FORMAT "99999999999999".
Hello, I've been trying to get this to work for ages now and I've ran out of options. No matter what I try, the value for a double/decimal is always invalid according to the Jquery validator. This is a list of what I tried:
Set culture in web.config
Set culture in CurrentThread
Change type from Decimal to Double
Change input type from Number to Text
Use globalize.js
Use a custom regex fix found on here
Use a DecimalBinder found on here
Nothing, absolutely nothing fixes this error. I'd greatly appreciate if somebody could point out what I was doing wrong here.
DisplayFormat.DataFormatString uses .NET's predefined formatting rules. In particular, the . (dot/period) is always interpreted to mean "the decimal point of the current culture", which in your case is ,, or comma.
If you want a literal dot separating the whole and fractional parts of the number, you need to escape it:
[DisplayFormat(DataFormatString = #"{0:0\.00}", ApplyFormatInEditMode = true)]
Using asp. Trying to format a decimal number to add commas. Are there simple to use functions or techniques in asp to go from a decimal value to currency format with commas?
Examples:
DecimalValue = 3439.01 CurrencyValue = " 3,439.01"
DecimalValue = 3843838.38 CurrencyValue = "3,843,838.00"
use the vbscript function FormatCurrency
complete syntax is:
FormatCurrency(Expression[,NumDigAfterDec[,
IncLeadingDig[,UseParForNegNum[,GroupDig]]]])
example:
FormatCurrency(20000)
output = $20,000.00
example of setting number of decimals:
FormatCurrency(20000,5)
output = $20,000.00000
To expand on Carlton Jenke's answer, there are 2 functions you can use for this (you mentioned formatting as a currency in the question title but don't include currency symbols in the body of the question):
formatnumber returns an expression formatted as a number.
formatcurrency returns an expression formatted as a currency value
using the currency symbol defined in the system control panel.
Both functions take the same arguments, those being:
Expression [,NumDigitsAfterDecimal [,IncludeLeadingDigit
[,UseParensForNegativeNumbers [,GroupDigits]]]]
Expression is the only required argument, that being the number
you wish to format.
NumDigitsAfterDecimal is a numeric value specifying how many
decimal places you want to round to. The default value is -1, which
indicates that the computer's regional settings should be used.
IncludeLeadingDigit is a tristate constant (see below) which
specifies whether or not you want to include a leading zero for
values between -1 and 1.
UseParensForNegativeNumbers is another tristate constant which
specifies whether or not you want negative values to be enclosed in
parentheses, rather than using a minus symbol.
GroupDigits, which is the argument you're after, is also a
tristate constant and is used to specify whether or not you want to
group numbers using the system's group delimiter.
The tristate constants takes one of the following for the value:
-2 is the default and indicates that the default value from the computer's regional setting should be used.
-1 is true.
0 is false.
there is a default Dollar Sign before the every Price tag. i want to change this to Thai Bhat of thailand. How can i do it?
Assuming your prices are contained within a span or a div elements using a class such as:
<span class="pricetag">$100,00.00</span>
A simple fix is to use jQuery to replace $ sign with thai baht symbol.
$('.pricetag').text().replace('$', '฿');
I don't know how you are displaying the value you can achieve it by
NumberFormatInfo numinfo = CultureInfo.CreateSpecificCulture("th-TH").NumberFormat;
textbox.Text = yourvalue.ToString("c",numinfo);
All you need to do is refer the Thai culture when considering the value of Price.
I am using this line :
FormatCurrency(DBReader("Price").ToString, 2, True)
to format my Currency
and I have two websites, the first one is English and the second is Arabic.
In the English website the price will be in $ Currency because the the localization setting is set as "en-US".
In the Arabic website the price will be in ل.ل Currency because the the localization setting is set as "ar-LB".
The question is how to format this code:
FormatCurrency(DBReader("Price").ToString, 2, True)
to make the currency in the $ only in both websites?
Check out the examples here, that use the overloaded toString function coupled with a format specifier and locale.
In your FormatCurrency method make use of NeutralCulture or en-US culture