Click here to Skip to main content
16,007,472 members
Home / Discussions / C#
   

C#

 
QuestionPassing different variable types Pin
mprice21413-Apr-10 4:51
mprice21413-Apr-10 4:51 
AnswerRe: Passing different variable types Pin
Luc Pattyn13-Apr-10 5:54
sitebuilderLuc Pattyn13-Apr-10 5:54 
GeneralRe: Passing different variable types Pin
dan!sh 13-Apr-10 6:12
professional dan!sh 13-Apr-10 6:12 
GeneralRe: Passing different variable types Pin
Luc Pattyn13-Apr-10 6:28
sitebuilderLuc Pattyn13-Apr-10 6:28 
GeneralRe: Passing different variable types Pin
dan!sh 13-Apr-10 6:46
professional dan!sh 13-Apr-10 6:46 
GeneralRe: Passing different variable types Pin
Luc Pattyn13-Apr-10 6:47
sitebuilderLuc Pattyn13-Apr-10 6:47 
GeneralRe: Passing different variable types Pin
DaveyM6913-Apr-10 8:25
professionalDaveyM6913-Apr-10 8:25 
GeneralRe: Passing different variable types Pin
mprice21413-Apr-10 6:30
mprice21413-Apr-10 6:30 
1.

mprice214 wrote:
RxString.Remove(0, 3); //This removes the first 4 characters

Not true. At best it removes 3 characters; and if there are fewer, expect an exception.

Yes, understand. I originally was removing 4.

2.


mprice214 wrote:
double.Parse (RxString);

that will fail if the data isn't really a string representation of a double. Don't do this on external data, it will bite you. Either add try-catch or better yet use TryParse().

Understand this too

3.
why does DisplayText() have parameters which make it look like a real event handler, you are not using those parameters, instead you are using some class member. It would seem logical to give it one parameter: the text it should display.

see #6

4.


mprice214 wrote:
serialPort1.WriteLine("*X01\r");

very strange. You want a carriage return plus whatever the system uses for a newline (maybe "\r\n"). Either you like what the system gives you, or you don't; I would never mix the two.

The device only requires a cr and as result, it is fine with just \r or \r and \n. Why would a newline be necessary here?

5.


mprice214 wrote:
catch (Exception Exception)
{
return;
}

This is not acceptable; whatever goes wrong, you ignore it. So when it goes wrong, you will have an impossible job to diagnose and fix the problem. And believe me, serial communication always goes wrong sooner or later. You should NOT swallow exceptions, either catch a very specific one and add a comment as to why you really don't care about it, or log it somewhere so it leaves a trail.

Understand. I am trying to get things working first and then am going back to clean up. As I'm relatively new to c#, I'm sure I'll miss some things.

6.


mprice214 wrote:
this.Invoke(new EventHandler(DisplayText));

That does not work, as the parameter list does not match. First make sure which parameters the method should have, then make sure to provide them, using an overload of Invoke().

When I run this, it works. Correct me if I am wrong, but doesn't this pass RxSring back to DisplayText? Are you saying there is a better way to do this?


Regarding the initial question, I need to pass RxString out of DisplayText as a double to use for graphing purposes.
GeneralRe: Passing different variable types Pin
Luc Pattyn13-Apr-10 6:46
sitebuilderLuc Pattyn13-Apr-10 6:46 
GeneralRe: Passing different variable types Pin
mprice21413-Apr-10 7:56
mprice21413-Apr-10 7:56 
GeneralRe: Passing different variable types Pin
Luc Pattyn13-Apr-10 8:02
sitebuilderLuc Pattyn13-Apr-10 8:02 
AnswerRe: Passing different variable types Pin
kevinnicol13-Apr-10 6:19
kevinnicol13-Apr-10 6:19 
GeneralRe: Passing different variable types Pin
mprice21413-Apr-10 6:32
mprice21413-Apr-10 6:32 
QuestionHow to Save the Excel file with some file format [modified] [Solved] Pin
yu-jian13-Apr-10 4:37
yu-jian13-Apr-10 4:37 
AnswerRe: How to Save the Excel file with some file format Pin
Dan Mos13-Apr-10 5:13
Dan Mos13-Apr-10 5:13 
Questiondatagrid checkbox Pin
Morgs Morgan13-Apr-10 4:26
Morgs Morgan13-Apr-10 4:26 
AnswerRe: datagrid checkbox Pin
J imran13-Apr-10 8:16
J imran13-Apr-10 8:16 
GeneralRe: datagrid checkbox Pin
Morgs Morgan13-Apr-10 9:33
Morgs Morgan13-Apr-10 9:33 
Questionsmart device Forms-Database Pin
Tunisien8613-Apr-10 2:18
Tunisien8613-Apr-10 2:18 
AnswerRe: smart device Forms-Database Pin
Luc Pattyn13-Apr-10 2:55
sitebuilderLuc Pattyn13-Apr-10 2:55 
AnswerRe: smart device Forms-Database [modified] Pin
Tim Yen13-Apr-10 2:55
Tim Yen13-Apr-10 2:55 
GeneralRe: smart device Forms-Database Pin
Luc Pattyn13-Apr-10 3:11
sitebuilderLuc Pattyn13-Apr-10 3:11 
GeneralRe: smart device Forms-Database Pin
Tunisien8613-Apr-10 4:17
Tunisien8613-Apr-10 4:17 
AnswerRe: smart device Forms-Database [modified] Pin
O.Phil13-Apr-10 4:11
O.Phil13-Apr-10 4:11 
GeneralRe: smart device Forms-Database Pin
Luc Pattyn13-Apr-10 4:20
sitebuilderLuc Pattyn13-Apr-10 4:20 

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.