By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,640 Members | 1,363 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,640 IT Pros & Developers. It's quick & easy.

Get currency code from ISO code WITHOUT needing culture info

100+
P: 116
Hi,

I have multiple possible currencies for an application and have the ISO codes (ie, USD, GBP). What I don't have is the culture (US,GB).

I need to convert the ISO code to the symbol which seems to be done with RegionInfo although this seems to want to use the culture info only to grab the other data.

How can I get the correct symbol, even if I have to loop through all region info to find it? (this is ok as will be done only once onload)

And then, once I have it can it be stored as, say, Dim usercurrency = ......?

Many thanks.
Aug 26 '13 #1

✓ answered by robertybob

This seems to work...

Expand|Select|Wrap|Line Numbers
  1. Imports System
  2. Imports System.Globalization
  3.  
  4. Public Class Form1
  5.  
  6.     Private usercurr = ""
  7.  
  8.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Load
  9.         Dim AllCultures() As CultureInfo
  10.         Dim ACulture As CultureInfo
  11.         Dim Rg As RegionInfo
  12.         Dim currstr As String= ""
  13.         Dim mycurrency = "GBP"
  14.  
  15.         AllCultures = CultureInfo.GetCultures(CultureTypes.SpecificCultures)
  16.         For Each ACulture In AllCultures
  17.             Rg = New RegionInfo(ACulture.LCID)
  18.             currstr = currstr & Rg.ISOCurrencySymbol + ": " + Rg.CurrencySymbol & vbCrLf
  19.             If Rg.ISOCurrencySymbol = mycurrency Then usercurr = Rg.CurrencySymbol
  20.         Next
  21.         TextBox1.Text = currstr
  22.         Label1.Text = usercurr
  23.     End Sub
  24. End Class
  25.  

Share this Question
Share on Google+
1 Reply


100+
P: 116
This seems to work...

Expand|Select|Wrap|Line Numbers
  1. Imports System
  2. Imports System.Globalization
  3.  
  4. Public Class Form1
  5.  
  6.     Private usercurr = ""
  7.  
  8.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Load
  9.         Dim AllCultures() As CultureInfo
  10.         Dim ACulture As CultureInfo
  11.         Dim Rg As RegionInfo
  12.         Dim currstr As String= ""
  13.         Dim mycurrency = "GBP"
  14.  
  15.         AllCultures = CultureInfo.GetCultures(CultureTypes.SpecificCultures)
  16.         For Each ACulture In AllCultures
  17.             Rg = New RegionInfo(ACulture.LCID)
  18.             currstr = currstr & Rg.ISOCurrencySymbol + ": " + Rg.CurrencySymbol & vbCrLf
  19.             If Rg.ISOCurrencySymbol = mycurrency Then usercurr = Rg.CurrencySymbol
  20.         Next
  21.         TextBox1.Text = currstr
  22.         Label1.Text = usercurr
  23.     End Sub
  24. End Class
  25.  
Aug 27 '13 #2

Post your reply

Sign in to post your reply or Sign up for a free account.