转换为货币时使用外币符号

时间:2014-09-04 19:27:07

标签: vb.net visual-studio-2012

'Declare Variables

Dim decPound As Decimal
Dim decYen As Decimal
Dim decEuro As Decimal

'Calculate
decPound = CDec((CDec(txtDollar.Text) / 1.63))
decEuro = CDec((CDec(txtDollar.Text) / 1.29))
decYen = CDec((CDec(txtDollar.Text) / 0.0095))

'Display
'Pounds
lblPounds.Text = (decPound).ToString("n2")
'Euro
lblEuros.Text = (decEuro).ToString("n2")
'Yen
lblYen.Text = (decYen).ToString("n2")

我希望不使用(" n2")使用像(" c"),而是让它显示为英镑,欧元或日元符号

1 个答案:

答案 0 :(得分:2)

您可以将相应的CultureInfo传递给ToString

lblPounds.Text = decPound.ToString("C", CultureInfo.CreateSpecificCulture("en-GB"))
lblEuros.Text = decEuro.ToString("C", CultureInfo.CreateSpecificCulture("de-DE"))
lblYen.Text = decYen.ToString("C", CultureInfo.CreateSpecificCulture("ja-JP"))

结果:

£61.35
77,52 €
¥10,526