serialport datareceived pls help me

pls help me guys..
I dont know why i can't make my if elseif statement do their job calling

label1.Text = "ALERT LEVEL!!!"
Timer1.Start()
Label2.Text = " Level 1 = Alert Level, Monitor the River for the possible Flood in Barangay."
Btnimage1.BackColor = Color.GreenYellow
Picmyimage.Image = My.Resources.nangka_plain_1

Here's my full vb.net code.

Public Class Form2
    Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        SerialPort1.Open()
    End Sub

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        If label1.ForeColor = Color.Black Then
            label1.ForeColor = Color.DimGray
        ElseIf label1.ForeColor = Color.DimGray Then
            label1.ForeColor = Color.Red
        ElseIf label1.ForeColor = Color.Red Then
            label1.ForeColor = Color.Gray
        ElseIf label1.ForeColor = Color.Gray Then
            label1.ForeColor = Color.Black

        End If

    End Sub
    Dim temblin As String
    Private Sub Serial_Port1_Datareceived(ByVal sender As Object, ByVal e As EventArgs) Handles SerialPort1.DataReceived
        temblin = SerialPort1.ReadLine
        Me.Invoke(New EventHandler(AddressOf DoUpdate))
    End Sub

    Public Sub DoUpdate()

        If temblin = "a" Then
            label1.Text = "ALERT LEVEL!!!"
            Timer1.Start()
            Label2.Text = " Level 1 = Alert Level, Monitor the River for the possible Flood in Barangay."
            Btnimage1.BackColor = Color.GreenYellow
            Picmyimage.Image = My.Resources.nangka_plain_1
        ElseIf temblin = "b" Then
            label1.Text = "WARNING LEVEL!!!"
            Timer1.Start()
            Btnimage2.BackColor = Color.RoyalBlue
            Label2.Text = " Level 2 = Warning Level, Anouncing a Warning and Evacuation to all residence of Barangay."
            Picmyimage.Image = My.Resources.nangka_plain_2
        ElseIf temblin = "c" Then
            label1.Text = "CRITICAL LEVEL!!!"
            Timer1.Start()
            Btnimage3.BackColor = Color.Red
            Label2.Text = " Level 3 = Critical Level, Forced Evacuation of all Residence in Barangay will be implemented."
            Picmyimage.Image = My.Resources.nangka_plain_3
        End If

    End Sub

End Class

You are asking about VB code in the Arduino programming forum. Is that what you meant to do ?

Im sorry I posted it on wrong category and I forgot to include my arduino codes thanks for askingsir :smiley:

Noobies94:
Im sorry I posted it on wrong category and I forgot to include my arduino codes thanks for askingsir :smiley:

But your not going to include the Arduino code?
Are you CERTAIN that the PC receives ONLY a "a"? Not "a"?

thanks for responding sir PaulS.
Here is my arduino code:

const int buttonPin = 2;
const int buttonPin1 = 4;
const int buttonPin2 = 6;
const int ledPin = 12;// the number of the pushbutton pin
const int ledPin1 = 13;
const int ledPin2 = 11;
const int buzzerPin = 8;
// the number of the LED pin

// variables will change:
int buttonState = 0;
int buttonState2 = 0;// variable for reading the pushbutton status
int buttonState3 = 0;
int newState = 0;

void setup() {
  Serial.begin(38400);
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);   
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(buzzerPin, OUTPUT);  
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT_PULLUP); 
  pinMode(buttonPin1, INPUT_PULLUP);
  pinMode(buttonPin2, INPUT_PULLUP);  
}

void loop(){
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH  && buttonState2 == LOW) {     
    // turn LED on:    
    digitalWrite(ledPin, HIGH);
    SendTextMessage();
    Serial.println("a");
delay(150);  
} 
  else {
    // turn LED off:
    digitalWrite(ledPin, LOW); 
  }
    
  buttonState2 = digitalRead(buttonPin1);
  if (buttonState2 == HIGH  && buttonState3 == LOW) {     
    // turn LED on:    
    digitalWrite(ledPin1, HIGH);
    SendTextMessage();
  Serial.println("b");  
delay(150);  
} 
  else {
    // turn LED off:
   
    digitalWrite(ledPin1, LOW); 
  }
  buttonState3 = digitalRead(buttonPin2);
  if (buttonState3 == HIGH) {     
    // turn LED on:    
    digitalWrite(ledPin2, HIGH);
    digitalWrite(buzzerPin, HIGH);
    SendTextMessage();
  Serial.println("c");  
 delay(150);
  } 
  else {
    // turn LED off:
   
    digitalWrite(ledPin2, LOW); 
    digitalWrite(buzzerPin, LOW);
  }
}
//**********************************************************
void SendTextMessage()
{
 Serial.print("AT+CMGF=1\r");
 delay(100);
 Serial.println("AT + CMGS = \"09108690901\"");
 delay(100);
 Serial.println("Warning");
 delay(100);
 Serial.println((char)26);
 delay(100);
 Serial.println();
}
    Serial.println("a");

So, you ARE sending "a" followed by carriage return and line feed, and then expecting just "a".

yes sir.
what am I suppose to do to make it right?

what am I suppose to do to make it right?

Search the string you receive for a carriage return. Replace it with a NULL, if found. Do the same for a line feed. The ASCII codes are 10 and 13.

tnx sir PaulS for always responding to my questions.
can u give me example code of what u are saying?
I am very sorry for me being too dumb...