title: Loading text from a file into a textbox
body: <p>I'm trying to place text from a text file in a textbox, but the textbox remains blank after the code executes. How can I fix this?</p>
  
  <pre><code>Dim fileno1 As Integer = FreeFile()
  FileOpen(fileno1, "C:\Users\main computer\Desktop\vb test\gyn-obs-D.txt", OpenMode.Input, OpenAccess.Read, OpenShare.Shared)
  Dim y As Boolean = 0
  Dim c = 0
  TextBox1.Text = "1"
  Do While Not EOF(fileno1)
      c += 1
      Dim txt As String = LineInput(fileno1)
      Debug.WriteLine(txt)
      Dim inputString As String = txt
  
      TextBox1.Text = txt
      If c = 40 Then
          y = 1
          Exit Do
      End If
      write1(inputString, y)
  Loop
  FileClose(fileno1)
  </code></pre>
  
  <p>edit: i added this class but still something wrong</p>
  
  <p>' of course these next two are at top
  Imports System
  Imports System.IO</p>
  
  <pre><code>Class Test
      Public Shared Sub Main()
          Try
              ' Create an instance of StreamReader to read from a file.
              ' The using statement also closes the StreamReader.
              Using sr As New StreamReader("TestFile.txt")
                  Dim line As String
                  ' Read and display lines from the file until the end of
                  ' the file is reached.
                  Do
                      line = sr.ReadLine()
                      If Not (line Is Nothing) Then
                          Console.WriteLine(line)
                      End If
                           textbox1.text=line  
                  Loop Until line Is Nothing
              End Using
          Catch e As Exception
              ' Let the user know what went wrong.
              Console.WriteLine("The file could not be read:")
              Console.WriteLine(e.Message)
          End Try
      End Sub
  End Class
  </code></pre>