I wrote following code. It's compile properly. when i enter 2 characters in to textbox at run time, it gives an error. Error is :
"String must be exactly one character long."
this is the program, I wote:

#pragma endregion
	private: System::Void btnSend_Click(System::Object^  sender, System::EventArgs^  e) {
				
				char caEntry[10];
				
				String ^ strTextBoxContent;
				strTextBoxContent = txtEntry->Text;

				caEntry[0] = strTextBoxContent[0];
				//caEntry[1] = strTextBoxContent[1];
				
				 serialPort1->Open();
				 serialPort1->Write(Convert::ToString(caEntry[0]));

				// serialPort1->Write(Convert::ToString(caEntry[1]));
				 serialPort1->Close();
			 }

I want to know how to separate the textbox content and it assign to the char array...
thank u...

You don't have to go through all this as Write() has an overload that takes a string directly. If you had to go the route you planned you can use the ToCharArray() method of the string to get the array that you need.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.