Public Class frmStates

  Dim states() As String = IO.File.ReadAllLines("USStates.txt")

  Private Sub btnFind_Click(ByVal sender As System.Object,
                            ByVal e As System.EventArgs) Handles btnFind.Click
    Dim sr As IO.StreamReader = IO.File.OpenText("USStates.txt")
    Dim abbrev As String = mtbAbbrev.Text.ToUpper
    Dim line As String
    Dim foundFlag As Boolean = False
    Do Until foundFlag Or sr.EndOfStream
      line = sr.ReadLine
      If line.Split(","c)(1) = abbrev Then
        txtName.Text = line.Split(","c)(0)
        foundFlag = True
      End If
    Loop
    If Not foundFlag Then
      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

