Click here to Skip to main content
15,868,016 members
Articles / Programming Languages / Visual Basic

International Number Formats

Rate me:
Please Sign up or sign in to vote.
3.00/5 (14 votes)
30 Apr 2010CPOL3 min read 97.6K   10   8
This article explains different number formatting based on locale

Introduction

Recently, I was surprised to discover that in addition to the standard US number format (1,234.67) and some European country format (1.234,56 and 1 234,56), there are other number formats. So I wrote a function that lists all of the number formats out there in VB.NET.

VB.NET
Public Function GetCultureSelect() As String
 Dim oHashtable As New Hashtable
 For Each oCultureInfo As System.Globalization.CultureInfo _
	In System.Globalization.CultureInfo.GetCultures_
	(System.Globalization.CultureTypes.AllCultures)
  Dim sKey As String = oCultureInfo.Name
  Dim sName As String = oCultureInfo.EnglishName
  Try
   Dim oNumberFormat As System.Globalization.NumberFormatInfo = oCultureInfo.NumberFormat
   Dim s As String = oNumberFormat.CurrencyDecimalSeparator
   Dim sFormat As String = "1" & oNumberFormat.CurrencyGroupSeparator & "234" & _
	oNumberFormat.CurrencyDecimalSeparator & "56"
   If oHashtable.ContainsKey(sFormat) = False Then
    oHashtable.Add(sFormat, sKey & " - " & sName)
   Else
    oHashtable(sFormat) += "<br>" & sKey & " - " & sName
   End If
  Catch ex As Exception
  End Try
 Next
 Dim sb As New System.Text.StringBuilder()
 sb.Append("<table border=1>" & vbCrLf)
 sb.Append("<tr><th>Format</th><th>Country</th></tr>" & vbCrLf)
 For Each oEntry As DictionaryEntry In oHashtable
  sb.Append("<tr><td valign=top>" & oEntry.Key & "</td><td>" & _
	oEntry.Value & "</td></tr>" & vbCrLf)
 Next
 sb.Append("</table>")
 Return sb.ToString()
End Function 

Here is the table this VB.NET function returns:

FormatCountry
1,234.56- Invariant Language (Invariant Country)
ar-SA - Arabic (Saudi Arabia)
zh-TW - Chinese (Taiwan)
en-US - English (United States)
he-IL - Hebrew (Israel)
ja-JP - Japanese (Japan)
ko-KR - Korean (Korea)
th-TH - Thai (Thailand)
ur-PK - Urdu (Islamic Republic of Pakistan)
hy-AM - Armenian (Armenia)
af-ZA - Afrikaans (South Africa)
hi-IN - Hindi (India)
sw-KE - Kiswahili (Kenya)
pa-IN - Punjabi (India)
gu-IN - Gujarati (India)
ta-IN - Tamil (India)
te-IN - Telugu (India)
kn-IN - Kannada (India)
mr-IN - Marathi (India)
sa-IN - Sanskrit (India)
kok-IN - Konkani (India)
syr-SY - Syriac (Syria)
dv-MV - Divehi (Maldives)
ar-IQ - Arabic (Iraq)
zh-CN - Chinese (People's Republic of China)
en-GB - English (United Kingdom)
es-MX - Spanish (Mexico)
ar-EG - Arabic (Egypt)
zh-HK - Chinese (Hong Kong S.A.R.)
en-AU - English (Australia)
ar-LY - Arabic (Libya)
zh-SG - Chinese (Singapore)
en-CA - English (Canada)
es-GT - Spanish (Guatemala)
ar-DZ - Arabic (Algeria)
zh-MO - Chinese (Macao S.A.R.)
en-NZ - English (New Zealand)
ar-MA - Arabic (Morocco)
en-IE - English (Ireland)
es-PA - Spanish (Panama)
ar-TN - Arabic (Tunisia)
en-ZA - English (South Africa)
es-DO - Spanish (Dominican Republic)
ar-OM - Arabic (Oman)
en-JM - English (Jamaica)
ar-YE - Arabic (Yemen)
en-029 - English (Caribbean)
ar-SY - Arabic (Syria)
en-BZ - English (Belize)
es-PE - Spanish (Peru)
ar-JO - Arabic (Jordan)
en-TT - English (Trinidad and Tobago)
ar-LB - Arabic (Lebanon)
en-ZW - English (Zimbabwe)
ar-KW - Arabic (Kuwait)
en-PH - English (Republic of the Philippines)
ar-AE - Arabic (U.A.E.)
ar-BH - Arabic (Bahrain)
ar-QA - Arabic (Qatar)
es-SV - Spanish (El Salvador)
es-HN - Spanish (Honduras)
es-NI - Spanish (Nicaragua)
es-PR - Spanish (Puerto Rico)
zu-ZA - Zulu (South Africa)
xh-ZA - Xhosa (South Africa)
tn-ZA - Tswana (South Africa)
quz-PE - Quechua (Peru)
cy-GB - Welsh (United Kingdom)
fil-PH - Filipino (Philippines)
iu-Latn-CA - Inuktitut (Latin) (Canada)
mi-NZ - Maori (New Zealand)
ga-IE - Irish (Ireland)
moh-CA - Mohawk (Canada)
ns-ZA - Northern Sotho (South Africa)
mt-MT - Maltese (Malta)
1.234,56ca-ES - Catalan (Catalan)
da-DK - Danish (Denmark)
de-DE - German (Germany)
el-GR - Greek (Greece)
is-IS - Icelandic (Iceland)
it-IT - Italian (Italy)
nl-NL - Dutch (Netherlands)
pt-BR - Portuguese (Brazil)
ro-RO - Romanian (Romania)
hr-HR - Croatian (Croatia)
sq-AL - Albanian (Albania)
sv-SE - Swedish (Sweden)
tr-TR - Turkish (Turkey)
id-ID - Indonesian (Indonesia)
sl-SI - Slovenian (Slovenia)
lt-LT - Lithuanian (Lithuania)
vi-VN - Vietnamese (Vietnam)
eu-ES - Basque (Basque)
mk-MK - Macedonian (Former Yugoslav Republic of Macedonia)
fo-FO - Faroese (Faroe Islands)
ms-MY - Malay (Malaysia)
gl-ES - Galician (Galician)
fr-BE - French (Belgium)
nl-BE - Dutch (Belgium)
pt-PT - Portuguese (Portugal)
sr-Latn-CS - Serbian (Latin, Serbia)
ms-BN - Malay (Brunei Darussalam)
de-AT - German (Austria)
es-ES - Spanish (Spain)
sr-Cyrl-CS - Serbian (Cyrillic, Serbia)
de-LU - German (Luxembourg)
es-CR - Spanish (Costa Rica)
es-VE - Spanish (Venezuela)
es-CO - Spanish (Colombia)
es-AR - Spanish (Argentina)
es-EC - Spanish (Ecuador)
es-CL - Spanish (Chile)
es-UY - Spanish (Uruguay)
es-PY - Spanish (Paraguay)
es-BO - Spanish (Bolivia)
sr-Cyrl-BA - Serbian (Cyrillic) (Bosnia and Herzegovina)
fy-NL - Frisian (Netherlands)
se-SE - Sami (Northern) (Sweden)
sma-SE - Sami (Southern) (Sweden)
hr-BA - Croatian (Bosnia and Herzegovina)
bs-Latn-BA - Bosnian (Bosnia and Herzegovina)
bs-Cyrl-BA - Bosnian (Cyrillic) (Bosnia and Herzegovina)
arn-CL - Mapudungun (Chile)
quz-EC - Quechua (Ecuador)
sr-Latn-BA - Serbian (Latin) (Bosnia and Herzegovina)
smj-SE - Sami (Lule) (Sweden)
quz-BO - Quechua (Bolivia)
1'234.56de-CH - German (Switzerland)
it-CH - Italian (Switzerland)
fr-CH - French (Switzerland)
de-LI - German (Liechtenstein)
rm-CH - Romansh (Switzerland)
1 234,56bg-BG - Bulgarian (Bulgaria)
cs-CZ - Czech (Czech Republic)
fi-FI - Finnish (Finland)
fr-FR - French (France)
hu-HU - Hungarian (Hungary)
nb-NO - Norwegian, Bokmål (Norway)
pl-PL - Polish (Poland)
ru-RU - Russian (Russia)
sk-SK - Slovak (Slovakia)
uk-UA - Ukrainian (Ukraine)
be-BY - Belarusian (Belarus)
lv-LV - Latvian (Latvia)
az-Latn-AZ - Azeri (Latin, Azerbaijan)
ka-GE - Georgian (Georgia)
uz-Latn-UZ - Uzbek (Latin, Uzbekistan)
tt-RU - Tatar (Russia)
mn-MN - Mongolian (Cyrillic, Mongolia)
nn-NO - Norwegian, Nynorsk (Norway)
sv-FI - Swedish (Finland)
az-Cyrl-AZ - Azeri (Cyrillic, Azerbaijan)
uz-Cyrl-UZ - Uzbek (Cyrillic, Uzbekistan)
fr-CA - French (Canada)
fr-LU - French (Luxembourg)
fr-MC - French (Principality of Monaco)
sma-NO - Sami (Southern) (Norway)
smn-FI - Sami (Inari) (Finland)
se-FI - Sami (Northern) (Finland)
sms-FI - Sami (Skolt) (Finland)
smj-NO - Sami (Lule) (Norway)
lb-LU - Luxembourgish (Luxembourg)
se-NO - Sami (Northern) (Norway)
1,234/56fa-IR - Persian (Iran)
1 234-56kk-KZ - Kazakh (Kazakhstan)
ky-KG - Kyrgyz (Kyrgyzstan)
1 234.56et-EE - Estonian (Estonia)

I hope someone might find this information useful.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United States United States
Igor is a business intelligence consultant working in Tampa, Florida. He has a BS in Finance from University of South Carolina and Masters in Information Management System from University of South Florida. He also has following professional certifications: MCSD, MCDBA, MCAD.

Comments and Discussions

 
QuestionDisplay Currency Symbol along with Price format Pin
Durgesh M. Patel6-Jun-16 1:10
Durgesh M. Patel6-Jun-16 1:10 
QuestionNice Igor! Pin
Volynsky Alex20-Apr-14 22:31
professionalVolynsky Alex20-Apr-14 22:31 
QuestionThanks! Pin
Friedrich Brunzema1-Sep-11 15:22
Friedrich Brunzema1-Sep-11 15:22 
GeneralMy vote of 1 Pin
TobiasP5-Sep-10 22:55
TobiasP5-Sep-10 22:55 
I'm afraid this article does not display international number formats - it displays international currency formats, though in some cases wrong as the currency numbers are not always grouped in digits of three the way this code does. An overload of Double.ToString() should have been used to get the number strings.
GeneralConvert Language or Text Pin
Anubhava Dimri15-Jun-10 19:21
Anubhava Dimri15-Jun-10 19:21 
GeneralTip Trick rather than an article Pin
Abhinav S8-Jun-10 18:43
Abhinav S8-Jun-10 18:43 
GeneralGood to remember Pin
tystent4-May-10 5:44
tystent4-May-10 5:44 
QuestionThe language-locale list needs some sorting Pin
M McMahon3-May-10 4:00
M McMahon3-May-10 4:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.