read button signal from arduino in to vb.net

hallo, I'm Ruben from Belgium and working on a project that make's a connection with arduino using a serial interface. I already found how to send commands to arduino (turn a led on and of with vb.net ). Now I want to read a serial port and that is where I'm stuck.

On the port 8 of the arduino uno is a button connected, this is the C++ code :

const int buttonPin = 8;
int buttonState = 0;


void setup(){
pinMode(buttonPin, INPUT);

Serial.begin(9600);

}
void loop()
{
buttonState = digitalRead(buttonPin);

if (buttonState == HIGH) {
Serial.println (1) ;
delay (10);
}
else {
Serial.println (0) ;
delay(10) ;

}

if (Serial.available()) {
delay(100);
while (Serial.available() > 0)

}
}

now I want to read this signal into vb.net ( check a checkbox ) I have tried it and it's doing nothing :(

is there some sort of basic code that a can insert in vb.net the read the serial ?

thanks ,

Ruben,

I was working on something similar which reads button presses from a PHP script on a Windows 7 PC. While I had no problem opening the port and writing to the Arduino serial interface, I did find that it hung while trying to read. Upon opening the Arduino Serial Monitor, I could confirm the Arduino code worked fine. Then I noticed that just opening the Serial Monitor seemed to "initialize" something, because after closing it, my PHP script could read from the Arduino fine and the whole project worked as designed.

Assuming you have correctly written Arduino and .NET code, you might try opening and closing the Serial Monitor window. Also, I verified that I do not have the problem on Linux - the PHP and Arduino work right after plug-in.

One more comment... Generally, the button test routine in the Arduino loop looks for the state change from one loop to the next. There are examples how to do this on the net. You can save the state to a variable and compare it the next time through the loop.

I checked the c++ program with the Arduino Serial Monitor and its give the right code when I push the button. I have begin to writhe the vb.net program and I already found the way to find the com8 port , the only problem now is to find a way to read the serial port ?

Ruben