Public Class frmStates

  Dim stateData As XElement = XElement.Load("USStates.xml")

  Private Sub btnFind_Click(ByVal sender As System.Object,
                            ByVal e As System.EventArgs) Handles btnFind.Click
    Dim query = From st In stateData.Descendants("state")
                Let name = st.<name>.Value
                Let abbrev = st.<abbreviation>.Value
                Where abbrev = mtbAbbrev.Text.ToUpper
                Select name
    If query.Count = 1 Then
      txtName.Text = query.First
    Else
      Dim str As String = " is not a valid state abbreviation."
      MessageBox.Show(mtbAbbrev.Text.ToUpper & str, "Error")
      mtbAbbrev.Clear()
      mtbAbbrev.Focus()
    End If
  End Sub

End Class

