Get currency code from ISO code WITHOUT needing culture info

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • robertybob
    New Member
    • Feb 2013
    • 116

    #1

    Get currency code from ISO code WITHOUT needing culture info

    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.
  • robertybob
    New Member
    • Feb 2013
    • 116

    #2
    This seems to work...

    Code:
    Imports System
    Imports System.Globalization
    
    Public Class Form1
    
        Private usercurr = ""
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Load
            Dim AllCultures() As CultureInfo
            Dim ACulture As CultureInfo
            Dim Rg As RegionInfo
            Dim currstr As String= ""
            Dim mycurrency = "GBP"
    
            AllCultures = CultureInfo.GetCultures(CultureTypes.SpecificCultures)
            For Each ACulture In AllCultures
                Rg = New RegionInfo(ACulture.LCID)
                currstr = currstr & Rg.ISOCurrencySymbol + ": " + Rg.CurrencySymbol & vbCrLf
                If Rg.ISOCurrencySymbol = mycurrency Then usercurr = Rg.CurrencySymbol
            Next
            TextBox1.Text = currstr
            Label1.Text = usercurr
        End Sub
    End Class

    Comment

    Working...