Click here to Skip to main content
15,890,882 members
Home / Discussions / C#
   

C#

 
QuestionBlank lines in a rich text box from a Serial Device, am I getting rid of them correctly..... Pin
glennPattonWork329-Aug-12 4:21
professionalglennPattonWork329-Aug-12 4:21 
AnswerRe: Blank lines in a rich text box from a Serial Device, am I getting rid of them correctly..... Pin
Pete O'Hanlon29-Aug-12 4:30
mvePete O'Hanlon29-Aug-12 4:30 
GeneralRe: Blank lines in a rich text box from a Serial Device, am I getting rid of them correctly..... Pin
glennPattonWork329-Aug-12 5:00
professionalglennPattonWork329-Aug-12 5:00 
GeneralRe: Blank lines in a rich text box from a Serial Device, am I getting rid of them correctly..... Pin
Pete O'Hanlon29-Aug-12 5:13
mvePete O'Hanlon29-Aug-12 5:13 
GeneralRe: Blank lines in a rich text box from a Serial Device, am I getting rid of them correctly..... Pin
glennPattonWork329-Aug-12 5:37
professionalglennPattonWork329-Aug-12 5:37 
GeneralRe: Blank lines in a rich text box from a Serial Device, am I getting rid of them correctly..... Pin
PIEBALDconsult29-Aug-12 6:05
mvePIEBALDconsult29-Aug-12 6:05 
GeneralRe: Blank lines in a rich text box from a Serial Device, am I getting rid of them correctly..... Pin
glennPattonWork329-Aug-12 6:15
professionalglennPattonWork329-Aug-12 6:15 
GeneralRe: Blank lines in a rich text box from a Serial Device, am I getting rid of them correctly..... Pin
PIEBALDconsult29-Aug-12 5:37
mvePIEBALDconsult29-Aug-12 5:37 
I'm pretty sure he didn't mean that. That would be silly.


glennPattonWork wrote:
I'm using the ReadExisting()


I would more likely use Read(Byte[], Int32, Int32), but ReadExisting should be OK unless you find it isn't (in the past I've had trouble with some communication equipment inserting NULLs that weren't sent by the device).

Anyway, once you have the incoming string, you can iterate the characters:

e.g. foreach ( char c in s ) ...

and only pass along the ones you need. Personally I would write a class that would do all this and fire events for incoming strings/lines:

0) Instantiate a StringBuilder
1) Loop until told to stop:
1.1) Read incoming data
1.2) Iterate the incoming data
1.2.1) If printing character (or TAB), append to StringBuilder
1.2.2) If Carriage Return, Raise event to send contents of StringBuilder, clear StringBuilder


You may want to look at my TelnetSocket[^] for a similar technique (I thought I had a Serial Port version too).
GeneralRe: Blank lines in a rich text box from a Serial Device, am I getting rid of them correctly..... Pin
glennPattonWork329-Aug-12 5:42
professionalglennPattonWork329-Aug-12 5:42 
GeneralRe: Blank lines in a rich text box from a Serial Device, am I getting rid of them correctly..... Pin
glennPattonWork329-Aug-12 6:14
professionalglennPattonWork329-Aug-12 6:14 
GeneralRe: Blank lines in a rich text box from a Serial Device, am I getting rid of them correctly..... Pin
PIEBALDconsult29-Aug-12 6:54
mvePIEBALDconsult29-Aug-12 6:54 
GeneralRe: Blank lines in a rich text box from a Serial Device, am I getting rid of them correctly..... Pin
glennPattonWork329-Aug-12 22:01
professionalglennPattonWork329-Aug-12 22:01 
GeneralRe: Blank lines in a rich text box from a Serial Device, am I getting rid of them correctly..... Pin
glennPattonWork329-Aug-12 23:19
professionalglennPattonWork329-Aug-12 23:19 
QuestionExtract excel from SQLDB Pin
dabuskol29-Aug-12 2:31
dabuskol29-Aug-12 2:31 
AnswerRe: Extract excel from SQLDB Pin
Eddy Vluggen29-Aug-12 2:42
professionalEddy Vluggen29-Aug-12 2:42 
GeneralRe: Extract excel from SQLDB Pin
dabuskol29-Aug-12 2:45
dabuskol29-Aug-12 2:45 
GeneralRe: Extract excel from SQLDB Pin
Eddy Vluggen29-Aug-12 3:01
professionalEddy Vluggen29-Aug-12 3:01 
Questionworking with xml Pin
sc steinhayse29-Aug-12 2:27
sc steinhayse29-Aug-12 2:27 
AnswerRe: working with xml Pin
Pete O'Hanlon29-Aug-12 2:35
mvePete O'Hanlon29-Aug-12 2:35 
GeneralRe: working with xml Pin
sc steinhayse29-Aug-12 3:49
sc steinhayse29-Aug-12 3:49 
GeneralRe: working with xml Pin
Pete O'Hanlon29-Aug-12 4:04
mvePete O'Hanlon29-Aug-12 4:04 
QuestionHow to get print from Zebra printng machine Tpl 2844 Pin
Mohammed Abdul Muqeet28-Aug-12 20:03
Mohammed Abdul Muqeet28-Aug-12 20:03 
AnswerRe: How to get print from Zebra printng machine Tpl 2844 Pin
Pete O'Hanlon28-Aug-12 23:08
mvePete O'Hanlon28-Aug-12 23:08 
QuestionC# take xml and store in sql server Pin
dcof28-Aug-12 18:00
dcof28-Aug-12 18:00 
AnswerRe: C# take xml and store in sql server Pin
PIEBALDconsult28-Aug-12 19:19
mvePIEBALDconsult28-Aug-12 19:19 

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.