title: Reading text from a command prompt in VB.net
body: <p>I have recently found this application called zbarcam that is a command prompt application that reads QR Codes from my webcam. It works great when I run it from the command prompt and it displays all the QR Code texts in the command prompt.</p>
  
  <p>Now I am trying to integrate its functionality into my VB.Net project, but, although I can load the application using StartInfo, I cannot read the QR codes that are displayed in the command prompt.</p>
  
  <p>Here is the code I am using:</p>
  
  <pre><code>    Dim myprocess As New Process
  
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
      With myprocess
        .StartInfo.FileName = "C:\Progra~2\ZBar\bin\zbarcam"
        .StartInfo.RedirectStandardOutput = True
        .StartInfo.UseShellExecute = False
        .Start()
      End With
      Timer1.Enabled = True
      Timer1.Start()
    End Sub
  
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
      resultsTextBox.Text = myprocess.StandardOutput.ReadToEnd
    End Sub
  </code></pre>
  
  <p>What I want to do is check for changes in the text in the command prompt once every second. However, when I run this code, the command prompt comes up as black and when I move my code in front of the camera, although it detects it (I can see the green box around the QR Code in the video preview), the text does not show in the command prompt.</p>
  
  <p>If I set "<em>.StartInfo.UseShellExecute</em>" to True and comment the line "<em>.StartInfo.RedirectStandardOutput = True</em>" and disable the timer, then the qr codes start showing in the command prompt, but I cannot read them!</p>
  
  <p>What is the best way to go about this? Ideally I wish to read from the command prompt only when there is a change, but if this cannot be done, then the next best thing is to poll the command prompt once a second and check for changes.</p>