I have been having a difficult time finding the proper way to pass string data that arrived thru the serial portby way ofthe DataReceived event, to a RichTextBox control on the main form. Moving from VB6 to VB2005 without using the automatic conversion helpers, has been more difficult that i hoped.
I have examined lots of newsgroup posts, looked at posted example code and still I am having trouble.
Some examples work, but appear to be automatically converted VB6 apps with Definstance properties and other items. I would rather understand the proper way to implement this starting from scratch ,using the form designer and the SerialPort control dragged to a form.
I have tried BeginInvoke and Delegate's and used various combinations suggested in other posts but still problems exist.
The serial port functions work fine and the receivied data is properly contained in the string variable in the DataReceived handler. Getting this data to the textbox is the issue.
I have tried using InvokeRequired to determine if BeginInvoke should be used.
Obviously i just do not understand, the concepts even after reading all i can find in MSDN articles.
Currently all builds just fine, but debugger error when data arrivies at DataReceived handler states that BeginInvoke cannot be called on a control until window handle has been created ??????? ( im not sure how that can be, as initial text has already been placed in the richtextbox control on the main form window before the SerialPort is created,opened or data has arrived)
Soin the displaySUB i placed .IsHandleCreated and if i call this Sub from the main form, to display something in the richtextbox, it shows handle created ok, but if i call this same sub from the DataReceived handler it indicates that the handle is not created, and that is why the InvokeRequired always ends up False an i never get serial data to display.
Does anyone have a codesnippet of the proper way to use DataReceived and a richtextbox display starting from placing the Serial Port control on the form ,and by way of a thread safe technique ...
I have looked at the C# example but have not been able to properly convert it toVB2005.