A
asam.reddy
Hi,
I am trying to read serial port using the MSComm control in
VS.NET2003(referred from the VS6.0). I have the code already in VB6
which I am coding to C#.NET.
After setting all the required settings of the COM1 Port
Dim buffer As Variant
Dim arr() As Byte
Dim myByte as string
buffer = MSComm1.Input
arr=buffer
myByte=arr[0]
Then comes the calculation part.
if((int)myByte=..)
For my first click on a drawing Board connected thru COM1, I am getting
myByte value as 132.(Same for all the initial clicks)
Now in C#,
string myByte=axMSComm1.Input.ToString();
ASCIIEncoding encoding=new ASCIIEncoding();
testByte=encoding.GetBytes(myByte);
int myFirstPoint=(int)(testByte [0]);
I am not getting the value 132,rather i m geting 63.
Please can anyone let me know the reason for this?
Both codes work for the same purpose but with different outputs.
Because we do not have a variant in C#(object is present but..) I am
not able to cast to the required result..
Please help me out in this regard..
Thank you
I am trying to read serial port using the MSComm control in
VS.NET2003(referred from the VS6.0). I have the code already in VB6
which I am coding to C#.NET.
After setting all the required settings of the COM1 Port
Dim buffer As Variant
Dim arr() As Byte
Dim myByte as string
buffer = MSComm1.Input
arr=buffer
myByte=arr[0]
Then comes the calculation part.
if((int)myByte=..)
For my first click on a drawing Board connected thru COM1, I am getting
myByte value as 132.(Same for all the initial clicks)
Now in C#,
string myByte=axMSComm1.Input.ToString();
ASCIIEncoding encoding=new ASCIIEncoding();
testByte=encoding.GetBytes(myByte);
int myFirstPoint=(int)(testByte [0]);
I am not getting the value 132,rather i m geting 63.
Please can anyone let me know the reason for this?
Both codes work for the same purpose but with different outputs.
Because we do not have a variant in C#(object is present but..) I am
not able to cast to the required result..
Please help me out in this regard..
Thank you