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)
  End Sub

  Private Sub btnDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
    Dim query = From city In MEGACITIESDataSet.Cities
                Join country In MEGACITIESDataSet.Countries
                On city.country Equals country.name
                Let cityName = city.name
                Let cityPop2010 = FormatNumber(city.pop2010, 1)
                Let cityPop2015 = FormatNumber(city.pop2015, 1)
                Let countryName = country.name
                Let countryPop2010 = FormatNumber(country.pop2010, 1)
                Select cityName, city.country, cityPop2010, cityPop2015,
                       countryName, countryPop2010, country.monetaryUnit
    dgvOutput.DataSource = query.ToList
    dgvOutput.CurrentCell = Nothing
  End Sub
End Class
