• We just launched and are currently in beta. Join us as we build and grow the community.

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

wakjdhlaw890

Checkpoint Master
W Rep
0
0
0
Rep
0
W Vouches
0
0
0
Vouches
0
Posts
67
Likes
13
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 200 XP
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:

countriesdisplay.png


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. ' this code access and passess the country name using the Globalization to String named CurrentComputerCulture
  3. CurrentComputerCulture =

    Globalization.

    RegionInfo

    .

    CurrentRegion

    .

    DisplayName
  4. For

    Each

    Country In

    Globalization.

    CultureInfo

    .

    GetCultures

    (

    Globalization.

    CultureTypes

    .

    InstalledWin32Cultures

    )
  5. 'change region
  6. My.

    Application

    .

    ChangeCulture

    (

    Country.

    Name

    )
  7. Countryname =

    Globalization.

    RegionInfo

    .

    CurrentRegion

    .

    DisplayName
  8. If

    ListBox1.

    Items

    .

    Contains

    (

    Countryname)

    =

    False

    Then
  9. 'add country name
  10. ListBox1.

    Items

    .

    Add

    (

    Countryname)
  11. lbox.

    Items

    .

    Add

    (

    Countryname &

    "/"

    &

    Globalization.

    RegionInfo

    .

    CurrentRegion

    .

    CurrencyNativeName

    &

    " = "

    &

    Globalization.

    RegionInfo

    .

    CurrentRegion

    .

    CurrencySymbol

    )
  12. End

    If
  13. 'clear cached data
  14. My.

    Application

    .

    Culture

    .

    ClearCachedData

    (

    )
  15. Next
  16. ' put the index to the countries in the listbox
  17. If

    lbox.

    Items

    .

    Count

    >

    0

    Then
  18. CountryIndex =

    ListBox1.

    FindString

    (

    CurrentComputerCulture)
  19. lbox.

    SelectedIndex

    =

    CountryIndex
  20. ListBox1.

    SelectedIndex

    =

    CountryIndex
  21. End

    If
  22. End

    Sub

Output:

countries.png


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


Download
You must upgrade your account or reply in the thread to view hidden text.
 

452,292

323,341

323,350

Top