0

我发现从这些代码行中我们可以得到加拿大的货币。

 Dim value As Decimal = ourTextbox.text 
    Dim positiveValue As Decimal = ourTextbox.text 
    Dim customCurrencyInfo As CultureInfo = CultureInfo.CreateSpecificCulture("fr-CA")

    customCurrencyInfo.NumberFormat.CurrencyNegativePattern = 8

    Dim formatString As String = value.ToString("C", customCurrencyInfo)
    Dim formatStringPositive As String = positiveValue.ToString("C", customCurrencyInfo)

    myTextbox.text = formatString
    myTextbox2.text = formatStringPositive

输出将是;

-123,45 美元 123,45 美元

但是这些国家呢:

-马来西亚-印度尼西亚 -
索马里
/非洲
-阿拉伯

如何在格式文本框中显示他们的货币?

4

1 回答 1

0

传递不同的文化名称作为CreateSpecificCulture()方法的参数,例如:

'Malaysia'
Dim customCurrencyInfo As CultureInfo = CultureInfo.CreateSpecificCulture("my-MY")
'Indonesia'
Dim customCurrencyInfo As CultureInfo = CultureInfo.CreateSpecificCulture("id-ID")
'Afrikaans'
Dim customCurrencyInfo As CultureInfo = CultureInfo.CreateSpecificCulture("af")
'Arabic'
Dim customCurrencyInfo As CultureInfo = CultureInfo.CreateSpecificCulture("ar")

您可以在 MSDN 中找到文化名称列表:CultureInfo Class

注意:更改文化信息不仅会更改货币符号,还可能更改小数点和千位分隔符。如果你想避免这种情况,你可以复制当前的文化

info and simply change it's currency symbol from other culture :
Dim customCurrencyInfo = (CultureInfo)CultureInfo.CurrentCulture.Clone();
Dim culture As CultureInfo = CultureInfo.CreateSpecificCulture("id-ID")
customCurrencyInfo.NumberFormat.CurrencySymbol = culture.NumberFormat.CurrencySymbol
于 2014-04-29T01:56:40.303 回答