title: Com Port Values changed when moved to form
body: <p>I have a <a href="http://www.micro-epsilon.com/download/manuals/man--optoNCDT-ILR-1181-1182--en.pdf" rel="nofollow noreferrer">distance tracking laser</a> hooked up to my COM1 port and I am using these settings to initialize the connection:</p>
  
  <pre><code>With ServoCalibrater.LaserPort
      .BaudRate = 19200
      .DataBits = 8
      .StopBits = IO.Ports.StopBits.One
      .Parity = IO.Ports.Parity.None
      .StopBits = IO.Ports.StopBits.One
      .Close()
      .Open()
      .Write("dt")
  End With
  </code></pre>
  
  <p>I then handle the received data with this function: (Reading is a global variable of type double and ErrorMessage is a global variable of type string)</p>
  
  <pre><code>Private Sub LaserPort_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles LaserPort.DataReceived
     ComRecv = True
     Dim TempRead As String
  
      TempRead = LaserPort.ReadExisting()
  
      If Not IsNumeric(TempRead) Then
          If Asc(TempRead) = 13 Then
              TempRead = "*No Data*"
          End If
          ErrorMessage = "Laser Error " &amp; TempRead &amp; "...  Please restart application, then turn laser off and back on."
      Else
          Reading = ErrorMessage
      End If
  End Sub
  </code></pre>
  
  <p>From here I want to get the <code>Reading</code> value onto my Form. I cannot do it directly in the method because it is not thread-safe. So my current attempted solution is to have a timer check the value of <code>Reading</code> every tenth of a second and add to the Form. I do so in this tick method:</p>
  
  <pre><code>Private Sub tmrMonitor_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrMonitor.Tick
      Dim MeasuredDistance As New clsDimension
      Dim DesiredDistance As New clsDimension
  
      'Check to see if we've got com with the laser so we can alert the user if not
      If Not ServoCalibrater.ComRecv Then
          LaserError.Text = "No communication received from the laser. Please check to make sure it's turned on."
      Else
          CurrentPosText.Text = Reading
          Refresh()
      End If
  End Sub
  </code></pre>
  
  <p>The code above seems to work perfectly when stepping through with the the debugger.
  However when the Form is displayed without the debugger the number displayed in CurrentPosText.Text is completely different from the expected value from the laser.</p>
  
  <p>I checked to make sure the laser values were correct by issuing the same commands through <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html" rel="nofollow noreferrer">Putty.exe</a>.</p>
  
  <p><a href="http://youtu.be/WrjJWbAg_dE" rel="nofollow noreferrer">Here</a> were the consistent results and settings from Putty. (Follow the link and Watch the video)</p>
  
  <p><strong><em>TLDR</em></strong> Watch <a href="http://youtu.be/hoPhQiUlcGc" rel="nofollow noreferrer">this video!</a></p>
  
  <p><img src="https://i.stack.imgur.com/9uILA.png" alt="enter image description here"></p>
  
  <p>How and why does the number I recieve from the COM port change when displayed on the form without the debugger?</p>