Public Class frmCities

  Private Sub frmCities_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    'TODO: This line of code loads data into the 'MegacitiesDataSet.Countries' table. You can move, or remove it, as needed.
    Me.CountriesTableAdapter.Fill(Me.MegacitiesDataSet.Countries)
    'TODO: This line of code loads data into the 'MegacitiesDataSet.Cities' table. You can move, or remove it, as needed.
    Me.CitiesTableAdapter.Fill(Me.MegacitiesDataSet.Cities)
    Dim query = From country In MegacitiesDataSet.Countries
            Order By country.monetaryUnit Ascending
            Select country.monetaryUnit
            Distinct
    lstCurrencies.DataSource = query.ToList
  End Sub



  Private Sub lstCurrencies_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstCurrencies.SelectedIndexChanged
    Dim query = From city In MegacitiesDataSet.Cities
            Join country In MegacitiesDataSet.Countries
            On city.country Equals country.name
            Where country.monetaryUnit = lstCurrencies.Text
            Order By city.name Ascending
            Select city.name
    lstCities.Items.Clear()
    If query.Count > 0 Then
      For Each city As String In query
        lstCities.Items.Add(city)
      Next
    Else
      lstCities.Items.Add("NONE")
    End If

  End Sub
End Class
