Click here to Skip to main content
15,893,722 members
Home / Discussions / C#
   

C#

 
GeneralRe: Converting string into non-string Form.Object types for passing to methods or updating non-string object.Property with strings Pin
Codice Fictor28-Nov-23 18:28
Codice Fictor28-Nov-23 18:28 
GeneralRe: Converting string into non-string Form.Object types for passing to methods or updating non-string object.Property with strings Pin
jschell29-Nov-23 4:56
jschell29-Nov-23 4:56 
GeneralRe: Converting string into non-string Form.Object types for passing to methods or updating non-string object.Property with strings Pin
Gerry Schmitz29-Nov-23 5:25
mveGerry Schmitz29-Nov-23 5:25 
QuestionQuestion Pin
Mo Fouad25-Nov-23 21:35
Mo Fouad25-Nov-23 21:35 
AnswerRe: Question Pin
Richard MacCutchan25-Nov-23 22:11
mveRichard MacCutchan25-Nov-23 22:11 
AnswerRe: Question Pin
Dave Kreskowiak26-Nov-23 4:42
mveDave Kreskowiak26-Nov-23 4:42 
GeneralRe: Question Pin
Richard Andrew x6426-Nov-23 6:28
professionalRichard Andrew x6426-Nov-23 6:28 
AnswerRe: Question Pin
Gerry Schmitz26-Nov-23 9:36
mveGerry Schmitz26-Nov-23 9:36 
GeneralRe: Question Pin
jschell27-Nov-23 6:17
jschell27-Nov-23 6:17 
QuestionC# error i dont know where i going wrong it say identifer expected in line 281 Pin
j k Nov202324-Nov-23 20:45
j k Nov202324-Nov-23 20:45 
AnswerRe: C# error i dont know where i going wrong it say identifer expected in line 281 Pin
Richard MacCutchan24-Nov-23 21:58
mveRichard MacCutchan24-Nov-23 21:58 
GeneralRe: C# error i dont know where i going wrong it say identifer expected in line 281 Pin
j k Nov202324-Nov-23 22:13
j k Nov202324-Nov-23 22:13 
GeneralRe: C# error i dont know where i going wrong it say identifer expected in line 281 Pin
Richard MacCutchan24-Nov-23 23:22
mveRichard MacCutchan24-Nov-23 23:22 
GeneralRe: C# error i dont know where i going wrong it say identifer expected in line 281 Pin
j k Nov202324-Nov-23 23:29
j k Nov202324-Nov-23 23:29 
GeneralRe: C# error i dont know where i going wrong it say identifer expected in line 281 Pin
Richard MacCutchan24-Nov-23 23:44
mveRichard MacCutchan24-Nov-23 23:44 
GeneralRe: C# error i dont know where i going wrong it say identifer expected in line 281 Pin
j k Nov202325-Nov-23 0:11
j k Nov202325-Nov-23 0:11 
GeneralRe: C# error i dont know where i going wrong it say identifer expected in line 281 Pin
Richard MacCutchan25-Nov-23 0:13
mveRichard MacCutchan25-Nov-23 0:13 
GeneralRe: C# error i dont know where i going wrong it say identifer expected in line 281 Pin
j k Nov202325-Nov-23 0:17
j k Nov202325-Nov-23 0:17 
GeneralRe: C# error i dont know where i going wrong it say identifer expected in line 281 Pin
Richard MacCutchan25-Nov-23 0:21
mveRichard MacCutchan25-Nov-23 0:21 
GeneralRe: C# error i dont know where i going wrong it say identifer expected in line 281 Pin
j k Nov202325-Nov-23 0:56
j k Nov202325-Nov-23 0:56 
GeneralRe: C# error i dont know where i going wrong it say identifer expected in line 281 Pin
j k Nov202324-Nov-23 23:32
j k Nov202324-Nov-23 23:32 
QuestionUpdate text box from serial data Pin
Iskander1234519-Nov-23 21:41
Iskander1234519-Nov-23 21:41 
I have a lines of data being written to a serial port. This data is in the following form
50 100 150 200 250 300 300 136 55 110 175 225 268 364 398 193


I am trying to make a C# application which would continously update 16 text boxes with these 16 values which are seperated by a tab. My current code just writes some garbage to the first textbox then the application closes. WHy?

void DataReceivedHandler(object sender, SerialDataReceivedEventArgs e)
        {
            string dataLine = serialPort1.ReadLine();
            if (dataLine == null || dataLine.Trim().Length == 0)
            {
                return;
            }

            // Split data into individual values
            string[] dataValues = dataLine.Split('\t');

            // Update text boxes with corresponding values
            textBox2.Text = dataValues[0];
            textBox3.Text = dataValues[1];
            textBox4.Text = dataValues[2];
            textBox5.Text = dataValues[3];
            textBox6.Text = dataValues[4];
            textBox7.Text = dataValues[5];
            textBox8.Text = dataValues[6];
            textBox9.Text = dataValues[7];
            textBox10.Text = dataValues[8];
            textBox11.Text = dataValues[9];
            textBox12.Text = dataValues[10];
            textBox13.Text = dataValues[11];
            textBox14.Text = dataValues[12];
            textBox15.Text = dataValues[13];
            textBox16.Text = dataValues[14];
            textBox17.Text = dataValues[15];

        }

        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                if (serialPort1.IsOpen)
                {
                    

                    // Register the data reception handler
                    serialPort1.DataReceived += DataReceivedHandler;

                    // Keep the program running until manually stopped
                    /*Console.WriteLine("Press any key to exit...");
                    Console.ReadKey();*/

                            
                }
                else
                {
                    MessageBox.Show("Error : Port needs to be open or wrong port selected!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

        }

AnswerRe: Update text box from serial data Pin
Victor Nijegorodov20-Nov-23 0:18
Victor Nijegorodov20-Nov-23 0:18 
AnswerRe: Update text box from serial data Pin
lmoelleb20-Nov-23 5:44
lmoelleb20-Nov-23 5:44 
AnswerRe: Update text box from serial data Pin
Gerry Schmitz20-Nov-23 6:39
mveGerry Schmitz20-Nov-23 6:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.