Serial Port Access using axMSComm

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top