Visual C# problem, SerialPort DataReceive
Hello,
I am trying to translate my Visual Basic program to C#.
Right now i am have having problems translating this code
[CODE]Private Sub SerialPort1_DataReceived(ByVal sender As System.Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
inchar = SerialPort1.ReadLine
IDstr = Microsoft.VisualBasic.Left(inchar, 2)
Datastr = Microsoft.VisualBasic.Right(inchar, 6)
result = Val("&h" & Datastr)
''Energy = (result * 38) / 1000
End Sub[/CODE]
I'd like to know how to make my IDstr read the most left 2 bits, and Datastr read the right most 6 bits.
For now i have this:
[CODE]private void DataReceivedHandler(object sender, SerialDataReceivedEventArgs e)
{
string inchar, IDstr, Datastr;
inchar = SerialPort1.ReadLine();
IDstr = Microsoft.VisualBasic.Left(inchar, 2); // need help translating this line
Datastr = Microsoft.VisualBasic.Right(inchar, 6); // need help translating this line
result = Val("&h" & Datastr);
/*''Energy = (result * 38) / 1000;*/
}[/CODE]
Thank you!