  Private Sub mnuOpen_Click(ByVal sender As Object, ByVal e As _
                 System.EventArgs) Handles mnuOpen.Click
    Dim FileName As String

    FileName = ""
    rtbOutput.Clear()
    With OpenFileDialog1
      .Filter = "Random files (*.dat)|*.dat|" & _
                "Text Files (*.txt)|*.txt|All " & _
                "Files (*.*)|*.*"
      .FilterIndex = 2
      .InitialDirectory = "C:\Temp\"
      .Title = "Select File"
    End With

    Try
      If OpenFileDialog1.ShowDialog() = DialogResult.OK Then 
        FileName = OpenFileDialog1.FileName
      Else
        Exit Sub     ' Nie chcą kontynuować...
      End If

      Select Case OpenFileDialog1.FilterIndex
        Case 1      ' O dostępie swobodnym
        Case 2      ' Tekst
          Dim MyReadText As StreamReader = New _
                        StreamReader(FileName)
          rtbOutput.Visible = True
          SizeRichTextbox()
          rtbOutput.Text = MyReadText.ReadToEnd()
          MyReadText.Close()
          MyReadText = Nothing
        Case Else
      End Select
    Catch
      MessageBox.Show("Something’s amiss...", "File Read Error")
    End Try
  End Sub
