Public Class frmStates

  Private Sub btnDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
    Dim stateData As XElement = XElement.Load("USStates.xml")
    Dim query = From st In stateData.Descendants("state")
                Let name = st.<name>.Value
                Let pop = CInt(st.<population>.Value)
                Let area = CInt(st.<area>.Value)
                Let density = pop / area
                Let formattedDensity = FormatNumber(density)
                Order By density Descending
                Where name.StartsWith("North")
                Select name, formattedDensity
    dgvStates.DataSource = query.ToList
    dgvStates.CurrentCell = Nothing
    dgvStates.Columns("name").HeaderText = "State"
    dgvStates.Columns("formattedDensity").HeaderText = "Density"
  End Sub

End Class

