Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
VB
Private Enum REPLY_FREQ As Integer
      NO_REPLY
      YES_REPLY
      TIMEOUT_REPLY
  End Enum
this compares to the C# version:
C#
enum REPLY : int { NO_REPLY, YES_REPLY, TIMEOUT_REPLY }


They are Set/Reset via the following
VB
'TmrNoDataAtPort.Enabled = False
    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
C#
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
Posted

1 solution

No, there is no difference. As far as I can remember, in the past, there were the versions when the syntax of VB.NET limiting its expression capabilities compared to C#. At present, even this is not the case, as event invocation is concerned.

After all, .NET BCL is the same, and even FCL is the same. (I don't count additional VB.NET specific assemblies, which I would not recommend to use. They are irrelevant to the topic of this question.) Please see:
http://en.wikipedia.org/wiki/Base_Class_Library[^],
http://en.wikipedia.org/wiki/Framework_Class_Library[^].

[EDIT]

And, if you mean handling interrupts, this does not happen in .NET at all, so using anything related to .NET cannot make any difference at all. Interrupts can be handled only on the kernel level of the OS. In case of Windows, it happens on the Ring #0 only. Please see:
http://en.wikipedia.org/wiki/Kernel_%28computing%29[^],
http://en.wikipedia.org/wiki/Architecture_of_Windows_NT[^],
http://en.wikipedia.org/wiki/Protection_ring[^].

—SA
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900