2014-09-04 26 views
1
'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」),但有它顯示了一個英鎊,歐元或日元符號代替轉換爲貨幣在使用外幣跡象

回答

2

你可以通過適當的CultureInfoToString

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 
+0

真棒!你知道我在哪裏可以得到不同國家的文化縮寫列表嗎? – 2014-09-05 01:10:20

+0

我不知道它是否完整:http://msdn.microsoft.com/en-us/goglobal/bb896001.aspx但它似乎。請記住接受答案(勾選綠色複選標記,[閱讀](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work))。 – 2014-09-05 05:11:57