Display All Countries in the World using Globalization in VB.NET

Today, I will teach you how to create a program that displays all countries in the world using globalization in VB.NET. Now, let's start this tutorial! 1. Let's start with creating a Windows Form Application for this tutorial by following the following steps in Microsoft Visual Studio: Go to File, click New Project, and choose Windows Application. 2. Next, add only one ListBox named ListBox1 to display the countries. You must design your interface like this: output 3. Now, we will do the coding. Initialize the following variables:
  1. 'to sort all the values of the listbox
  2.     Dim lbox As New ListBox With {.Sorted = True}
  3. ' determines the name of the country
  4.     Dim Countryname, CurrentComputerCulture As String
  5. ' determines the index of the country in the ListBox
  6.     Dim CountryIndex As Int32
For the Form_Load, have this code below:
  1.  Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  2.  
  3. ' this code access and passess the country name using the Globalization to String named CurrentComputerCulture
  4.         CurrentComputerCulture = Globalization.RegionInfo.CurrentRegion.DisplayName
  5.         For Each Country In Globalization.CultureInfo.GetCultures(Globalization.CultureTypes.InstalledWin32Cultures)
  6.             'change region
  7.             My.Application.ChangeCulture(Country.Name)
  8.             Countryname = Globalization.RegionInfo.CurrentRegion.DisplayName
  9.             If ListBox1.Items.Contains(Countryname) = False Then
  10.                 'add country name
  11.                 ListBox1.Items.Add(Countryname)
  12.                 lbox.Items.Add(Countryname & "/" & Globalization.RegionInfo.CurrentRegion.CurrencyNativeName & " = " & Globalization.RegionInfo.CurrentRegion.CurrencySymbol)
  13.             End If
  14.             'clear cached data
  15.             My.Application.Culture.ClearCachedData()
  16.         Next
  17. ' put the index to the countries in the listbox
  18.         If lbox.Items.Count > 0 Then
  19.             CountryIndex = ListBox1.FindString(CurrentComputerCulture)
  20.             lbox.SelectedIndex = CountryIndex
  21.             ListBox1.SelectedIndex = CountryIndex
  22.         End If
  23.     End Sub

Output:

output For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below. Best Regards, Engr. Lyndon Bermoy IT Instructor/System Developer/Android Developer/Freelance Programmer Mobile: 09488225971 Landline: 826-9296 E-mail:[email protected] Add and Follow me on Facebook: https://www.facebook.com/donzzsky Visit and like my page on Facebook at: https://www.facebook.com/BermzISware

Add new comment