Hi,
I'm new to the world of Visual Studio .Net (but have done a fair bit
of VB6 coding). I'm playing with the sample RS232 code from the MSDN
website (http://msdn.microsoft.com/msdnmag/is.../default.aspx).
I'm trying to get to grips with inheritance and the examples in the
above, but have stumbled trying to do the following: From the code
available at the above link, I've got the examples working. I'm trying
to modify the code to make my own send/receive routine (with
appropriate timeouts, but thats to follow).
In the lineterm.vb file I've created the following:
Public Sub SendCommand(ByVal cmd As String)
t.Send(cmd)
While strReceived = ""
Application.DoEvents()
End While
...
which sends the command and waits for strReceived to get something in
it. strReceived should be loaded by the following:
Protected Overrides Sub OnRxLine(ByVal s As String)
strReceived = s
End Sub
(strReceived is a global string declared outside of the above two
routines)
If I step through the code (initially in the above while loop of the
SendCommand routine), then strReceived has nothing in it. Then I send
something serially and OnRxLine executes and strReceived has the
received string in it. However, if I then single step again, the next
time the code is in the while loop, strReceived is back to nothing
again.
I suspect I've missed something very basic (but very important) to do
with how the Overrides OnRxLine sub is executing and why the
strReceived variable is not shared between that and my SendCommand
routine.
Any help received with thanks.
Regards
Malcolm.