title: How to open a .txt file and display it in a text box using Visual Basic 2008 Express Edition
body: <p>I am using <a href="http://en.wikipedia.org/wiki/Microsoft_Visual_Studio_Express#Visual_Basic_Express" rel="nofollow">Visual Basic 2008 Express Edition</a>, and this is very new to me. I have a browse button, and I added code in such a way that a file is browsed and its path is displayed in a label box when I click the browse button.</p>
  
  <p>Similarly I want the content of the file I select to be displayed in text box. I use the following code:</p>
  
  <pre><code>    Imports System.IO.StreamReader
      Dim oReader As StreamReader
  
      OpenFileDialog1.CheckFileExists = True
      OpenFileDialog1.CheckPathExists = True
      OpenFileDialog1.DefaultExt = "txt"
      OpenFileDialog1.FileName = ""
      OpenFileDialog1.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"
      OpenFileDialog1.Multiselect = False
  
      If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
          oReader = New StreamReader(OpenFileDialog1.FileName, True)
          RichTextBox1.Text = oReader.ReadToEnd
      End If
  </code></pre>
  
  <p>But I got syntax a error for the <code>Imports</code> line and <a href="https://msdn.microsoft.com/en-us/library/system.io.streamreader%28v=vs.110%29.aspx" rel="nofollow">StreamReader</a> as undeclared. How can I fix this problem?</p>