Hello to all,

Sorry to bother you guys, but I need your help, as I was reading the forum during whole last week and did not found the answer. I am new in Visual Basic, but want to learn, so I installed Visual Studio 2017 and wrote the Arduino sketch. So, the idea is to send Arduino <1> or <2>, etc., over the serial and have a string of HEXes back. With Arduino Serial Monitor and Windows Hyper Terminal it works as a charm, I send and receive the data. But the same idea in VS is not working normally. The code:

Private Sub button_READ_RAW_DATA_Click(sender As Object, e As EventArgs) Handles button_READ_RAW_DATA.Click
If (serialPort1.IsOpen) Then
Dim raw_data_in As String = serialPort1.ReadExisting
tBox_RAW_DATA.Text += raw_data_in & vbCrLf & vbCrLf
End If
End Sub

There were second button READ_DECODED_DATA and another tBox for it (sending <2>), but I removed it for troubleshooting purposes. It should send the <1> and take the Arduino response, and put it in a tBox, but it works strange. At first run of the app and first press of the button I have only two line feeds (vbCrLf), but no data in teh tBox (Arduino sends the data for sure, I can see the LEDs blinking). If I would press the button second time - if writes the data to appropriate tBox. When I have two buttons it was almost the same - on the first run and first press of any button I had nothing from Arduino, just line feeds. If I press the same button again - it gives the data, but if the second press would be a different button than previous - it still gives the first button data. This led me to the thought, that the button reads the new data, but writes the old data from previous click. So the second press of the same button gives the old data to tBox and reads the new data and stores it for some reason. That also explains, why I don't have anything on the first run of the app - it does not have anything from before, but reads the new data to some memory, instead of just putting it to the tBox. Why this is happening and how to correct it ? I want to understand, so please, dont be shy with explanations :).

Another thing from the same app, so I wouldn't have to create new thread. I am taking the COM port settings from tBoxes with code:

serialPort1.PortName = cBox_COM_PORT.SelectedItem
serialPort1.BaudRate = cBox_BAUD_RATE.SelectedItem
serialPort1.DataBits = cBox_DATA_BITS.SelectedItem
serialPort1.StopBits = IO.Ports.StopBits.One
serialPort1.Parity = IO.Ports.Parity.None

First three are taken from the tBoxes normally, but the Stopbits and Parity I cant make it work with tBoxes, so made it like this for testing. The tBoxes has a Collection fields with One and Two for Stop Bits and None, Odd, Even for Parity. How to make it somehow parse the selected settings in tBoxes to the appropriate COM port settings ?

Thank you all for support, have a great and sunny day with good mood all the week !