c++ visual studio form application serially reading data from arduino

hi!

iv made a c++ form application using visual studio. i want to read a string, serially printed/transmitted from my arduino mega and show the string on a text box in my form application. i have tried ReadLine() and a few other functions but I am unable to do so.

this is the arduino code:

String str;

void setup()
{
  Serial.begin(9600);
  
}

void loop()
{
  Serial.println("hello");
  delay(2000);
}

i have inserted a text box and a button on my form application. i want the hello to be saved in a string and want it to appear on the text box.
(or if therez a way to serially read characters, that can do my job too)

need help with the c++ code for the form application for this :confused: any kind of help will be appreciated!

I've not experimented with this class, but see if this might help:

need help with the c++ code for the form application for this

But you have not shown any code for the PC side.

Frankly, C++ is a crappy way to build forms applications that deal with the serial port (or that don't, for that matter).

C# makes developing forms apps so much simpler, and reading and writing from the serial port is trivial. Check out the attached application, if you want to go the easy route.

CommunicateWithArduino.zip (54 KB)

Thankyou econjack and PaulS for your help! i will surely try these methods