Receiving String From UNO R3 To VB.Net

Hy guys... Sorry, i'm a newbie on arduino programming. I have a small project with Visual Studio 2010 (VB.Net) and i want to receive string from my UNO. But, i've many ways and it still receive wrong string in my VB.Net. I try to find the solution, but i found nothing that work for my project. Here half of my sketch :

void setup(){
  String SerStr;
  while (Serial.available()> 1){
  char S = Serial.read();
  SerStr += S;
}

if (SerStr.length()> 2){
  if(SerStr=="L1"){
    digitalWrite(12, HIGH);
    }
  else if(SerStr=="L0"){
    digitalWrite(12,LOW);
  }
}
Stat = digitalRead(12);
  if (Stat==1){
    Serial.print("LR1");
  }
  else{
    Serial.print("LR0");
  }

So, when i send L1 on Serial Monitor or send it directly from my VB.Net, it will send LR1 continuously to my VB. But, i check the string in my VB, sometimes it only combination of L,R, and 1. Even, sometime i receive many string. How to receive only LR1 or LR0 ?

Thanks, Sorry For My Bad English

Here half of my sketch

Would you like half of an answer?

  while (Serial.available()> 1){
  char S = Serial.read();

Without calling Serial.begin()? Rather pointless.

So, when i send L1 on Serial Monitor or send it directly from my VB.Net, it will send LR1 continuously to my VB. But, i check the string in my VB, sometimes it only combination of L,R, and 1. Even, sometime i receive many string. How to receive only LR1 or LR0 ?

You need to post your VB code.

Sorry, this is my complete sketch , i've change some code tonight.

void setup() {
  pinMode(12, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(13, OUTPUT);
  pinMode(7, INPUT);
  pinMode(6, INPUT);
  Serial.begin(9600);
}

void loop() {
  //========================================================
  // Deklarasi Variabel 
  String baca;
  int Sen1 = 0;
  int Sen2 = 0;
    // =======================================================
  // Serial Monitor
  while (Serial.available() > 0) {
  char k =Serial.read();
  baca += k;
  }
  //========================================================
  // Proses Perintah
  if (baca.length()> 2){
     Serial.println(baca);
      if (baca=="LR1"){
        digitalWrite(12,HIGH);
      }
      else if (baca=="LR0"){
        digitalWrite(12,LOW);
      }
      else if (baca=="LS1"){
        digitalWrite(11, HIGH);
      }
      else if (baca=="LS0"){
        digitalWrite(11, LOW);
      }
  }
  //========================================================
  // Baca Sensor
  Sen1 = digitalRead(7);
  Sen2 = digitalRead(6);
  //========================================================
  
  delay(1000);
  if (Sen1==1){
    Serial.print("LR1");
  }
  else{
    Serial.print("LR0");
  }
  delay(1000);
  if (Sen2==1){
    Serial.print("LS1");
    }
  else{
    Serial.print("LS0");
  }
  digitalWrite(13, HIGH);
  delay(100);
  digitalWrite(13, LOW);
  delay(100); 
}

This my VB code when i press the ON button, VB send LR1 to Arduino and my Led going ON.

    Private Sub LsFRON_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LsFRON.Click
            SPort.Write("LR1")
    End Sub

This when i press OFF buttom

    Private Sub LsFROff_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LsFROff.Click
            SPort.Write("LR0")
    End Sub

This when VB receive data from Arduino

    Private Sub SPort_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SPort.DataReceived
        TerimaData(SPort.ReadExisting())
    End Sub

    Private Sub TerimaData(ByVal [text] As String)
        If reciv.InvokeRequired Then
            Dim X As New SetTextCallBack(AddressOf TerimaData)
            Me.Invoke(X, New Object() {(text)})
        Else
            Me.reciv.Text &= [text]
            Ram &= [text] 
            StatusJalur()
        End If
    End Sub
me.reciv.text &= [tex]  // Recieve data and send to RichTextBox
Ram &= [text]  // Ram is String, i use it to analize received data.

I use break point in VB to analize the data has been received. How to receive only LR1, LR0, LS1, and LS0 at a time?

How to receive only LR1, LR0, LS1, and LS0 at a time?

Change how SPort_DataReceived() is defined to be called. Typically, you want the function called when a certain character arrives - such as carriage return or line feed, not when any character arrives.

Then, change the Arduino code to send that trigger character. Simplest is to use carriage return or line feed as the trigger, and use println() instead of print().