Click here to Skip to main content
15,886,780 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi, I am sure this is a very easy question for most of you, but forgive me.

I need to read the Serial Error. Something along the lines of...
private void serialPort1_ErrorReceived(object sender, System.IO.Ports.SerialErrorReceivedEventArgs e)
       {
           SerialError = String CommErr;

       }

I know its a type but dont know how to read it to a message box.

Many many thanks.
Posted
Updated 18-Apr-13 11:12am
v2
Comments
Richard C Bishop 18-Apr-13 17:14pm    
When declaring and instantiating a variable, the datatype always goes on the left. It should be something like this:

string CommErr = SerialError;

Now depending on what SerialError is, you might need to call the ToString() or a property that displays its text value.
Sergey Alexandrovich Kryukov 18-Apr-13 17:57pm    
Also, it's not a string. Please see my answer. It's really difficult to help, at this phase...
—SA

1 solution

Probably you mean SerialErrorReceivedEventArgs.EventType, its type is not string but System.IO.Ports.SerialError:
http://msdn.microsoft.com/en-us/library/system.io.ports.serialerrorreceivedeventargs.aspx[^],
http://msdn.microsoft.com/en-us/library/system.io.ports.serialerrorreceivedeventargs.eventtype.aspx[^],
http://msdn.microsoft.com/en-us/library/system.io.ports.serialerror.aspx[^].

So, it could be
C#
System.IO.Ports.SerialError error = e.EventType;


Look, no matter what you want to achieve, it's apparent from your attempt to write code, that it is absolutely useless to write anything at all, at this level of knowledge. You can come back after you read some manual on programming, .NET and language from the very first page and learn how to write basic exercises. Think it would need too much time? But if you don't do it, you can waste a lot more, waste, instead of using time.

—SA
 
Share this answer
 

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