Click here to Skip to main content
15,886,963 members
Home / Discussions / C#
   

C#

 
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 
AnswerRe: Update text box from serial data Pin
jschell20-Nov-23 7:34
jschell20-Nov-23 7:34 
GeneralRe: Update text box from serial data Pin
Iskander1234520-Nov-23 19:29
Iskander1234520-Nov-23 19:29 
GeneralRe: Update text box from serial data Pin
jschell21-Nov-23 5:21
jschell21-Nov-23 5:21 
QuestionSystem.Data.SQLite.SQLiteException: 'SQL logic error no such table: Incident' Pin
Member 1612194217-Nov-23 3:09
Member 1612194217-Nov-23 3:09 
AnswerRe: System.Data.SQLite.SQLiteException: 'SQL logic error no such table: Incident' Pin
Dave Kreskowiak17-Nov-23 3:25
mveDave Kreskowiak17-Nov-23 3:25 
AnswerRe: System.Data.SQLite.SQLiteException: 'SQL logic error no such table: Incident' Pin
trønderen17-Nov-23 3:46
trønderen17-Nov-23 3:46 
GeneralRe: System.Data.SQLite.SQLiteException: 'SQL logic error no such table: Incident' Pin
Member 1612194217-Nov-23 4:02
Member 1612194217-Nov-23 4:02 
GeneralRe: System.Data.SQLite.SQLiteException: 'SQL logic error no such table: Incident' Pin
Dave Kreskowiak17-Nov-23 5:33
mveDave Kreskowiak17-Nov-23 5:33 
GeneralC# 12: New opportunities for auto-foot-wounding Pin
Richard Deeming16-Nov-23 0:24
mveRichard Deeming16-Nov-23 0:24 
GeneralRe: C# 12: New opportunities for auto-foot-wounding Pin
Richard MacCutchan16-Nov-23 1:11
mveRichard MacCutchan16-Nov-23 1:11 
GeneralRe: C# 12: New opportunities for auto-foot-wounding Pin
jschell16-Nov-23 5:18
jschell16-Nov-23 5:18 
QuestionC#, Winforms, Coding Pin
Hoàng Anh Quốc4-Nov-23 0:00
Hoàng Anh Quốc4-Nov-23 0:00 
AnswerRe: C#, Winforms, Coding Pin
Richard MacCutchan4-Nov-23 0:11
mveRichard MacCutchan4-Nov-23 0:11 
AnswerRe: C#, Winforms, Coding Pin
Andre Oosthuizen10-Nov-23 6:28
mveAndre Oosthuizen10-Nov-23 6:28 

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.