Hi All,
I have some code I have written in C# and am having to convert it to VB.NET for a purpose. I am seeing some difference in the way VB handles the Data Received event. In C# as far as I can tell data arrives at the port, the flag is raised and the data is collected to be processed. I commonly handle this with an Enum as detailed in
Serial Comms in C# for Beginners[
^] I have tried a similar system in VB and it appears it isn't reading the data correctly almost like each piece of data arrives and set the handle again. This is impossible (right ?) as both languages compile to the same IL code. Meaning there must be something I am not doing right with the Enum list
Private Enum REPLY_FREQ As Integer
NO_REPLY
YES_REPLY
TIMEOUT_REPLY
End Enum
this compares to the C# version:
enum REPLY : int { NO_REPLY, YES_REPLY, TIMEOUT_REPLY }
They are Set/Reset via the following
If (Reply_Status = REPLY_FREQ.TIMEOUT_REPLY) Then
Data_Back_1823A = "TIMEOUT"
ElseIf (Reply_Status = REPLY_FREQ.YES_REPLY) Then
NoDataAtPort_Freq.Enabled = False
End If
for the VB version and the C# version is for example
else if (Reply_Status == (int)REPLY.YES_REPLY)
{
Data_From_ATE = ATEComPort.ReadTo("\r\n");
if ((Data_From_ATE.Substring(0, 1)) == (Data_To_ATE.Substring(1, 1)))
{
return (Data_From_ATE);
}
}
else
{
Data_From_ATE = "SERIOUS_ERROR";
return (Data_From_ATE);
}
}
I have only used VB6 in anger (until now!) and jumped ship to C# as soon as I could after a brief (I mean brief!) wander in Borland C++ builder...
Any Ideas anyone?
Glenn