Public Class frmPresident

  Private Sub btnDisplay_Click(ByVal sender As System.Object,
                               ByVal e As System.EventArgs) Handles btnDisplay.Click
    Dim sr As IO.StreamReader
    Dim message As String
    Try
      sr = IO.File.OpenText("E:\DataFiles\USPres.txt")
      message = "The first President was " & sr.ReadLine & "."
      MessageBox.Show(message, "President")
    Catch exc As IO.DirectoryNotFoundException
      message = "The requested folder is not on the CD."
      MessageBox.Show(message, "Error")
    Catch exc As IO.FileNotFoundException
      message = "The file is not in the specified folder of the CD."
      MessageBox.Show(message, "Error")
    Catch exc As IO.IOException
      message = "Check to see if there is a CD in drive E:."
      MessageBox.Show(message, "Error")
    Finally
      Try
        sr.Close()
      Catch
        'Disregard any exceptions during the Close() method
      End Try
    End Try
  End Sub

End Class
