Click here to Skip to main content
15,117,830 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
hello all,,
I'am a student (i'am sorry if my english very bad)

I have a little problem with the GUI and microcontroller project that I created,
I will send two sample data from the microcontroller to the computer using serialports, I sent from the microcontroller using the C language printf ("@% 02d% 04d \ r", temp, count);
i sent using serialports setting on CodeVisionAVR compiler software:
/ / USART initialization
/ / Communication Parameters: 8 Data, 1 Stop, No Parity
/ / USART Receiver: On
/ / USART Transmitter: On
/ / USART Mode: Asynchronous
/ / USART Baud Rate: 9600

when the GUI is run the data received and displayed on a RichTextBox looks so perfect, the data are shown like with the transfer by the microcontroller.
but when data is received and i split it with two variables temp and count, I found the problem there.
I want to get the data to ( double or integer variabel) clean and precise. Can you help me??,, i'am very happy for that
thank you.

tihis script on my GUI visual C#
private string RxString;
private void serialPort1_DataReceived
(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
RxString = serialPort1.ReadExisting();
this.Invoke(new EventHandler(DisplayText));

private string data_all,head,data1,data2;
private double data1a,data2a;
private void DisplayText(object sender, EventArgs e)
if(RxString.Length >= 8)
head =RxString. Substring(0, 1);
if(head == '@')
data2 = RxString.Substring(1, 2);
data1 = RxString.Substring(3, 4);
data1a = Convert.ToDouble (data1);
data2a = Convert.ToDouble(data2);
this.segmentGauge1.Value = data2a;
this.segmentGauge2.Value = data1a;
Script? Let's start with the obvious: C# is not a scripting language. Now, what's your question?
tetuko99 3-Jun-12 4:10am
point of my problem is,,
i want to get numeric data (int or double) from texbox data viewed.
but that my be real ??

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900