title: Waiting for exact value from SERIAL PORT VB.net
body: <p>I'm trying to wait microcontroller print "OK" to Serial Port, and VB.net check that "OK" and assign that value to string variable - check_OK. The first problem i faced - its data recevied event handler i just dont know how to make it check for exact value from serial port. I used Richtextbox1 to save ok from serial port then trying make its value = check_OK. I tried like this: </p>
  
  <pre><code>Public Class Form1
  Dim check_OK As String
  Dim OK_rs As Byte
  
  Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  
  End Sub
  Private Sub SerialPort1_DataReceived(sender As Object, e As SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
      ReceivedText(SerialPort1.ReadExisting())
  End Sub
  Private Sub ReceivedText(ByVal [text] As String)
      If Me.RichTextBox1.InvokeRequired Then
          Dim x As New SetTextCallback(AddressOf ReceivedText)
          Me.Invoke(x, New Object() {(text)})
  
      Else
          Me.RichTextBox1.Text = ""
          Me.RichTextBox1.Text &amp;= [text]
          If RichTextBox1.Text = "O" Or RichTextBox1.Text = "K" Then
              check_OK = check_OK &amp; RichTextBox1.Text
          End If
      End If
  End Sub
  </code></pre>