Hi for those who understand VB6.
I found some code and added it in my project to remotely see some data at the PC
//send data to serial port for debugging/read data at the PC Serial.println(sensorValue); //max 3 digits Serial.println(brakeValue); //max 3 digits Serial.println(speedcurveValue); //max 3 digits Serial.println(brakecurveValue); //max 3 digits Serial.println(speedstartValue); //max 3 digits Serial.println ("\t"); //use this to indicate end of datastream for next loop to detect delay(50);
While reading the data at the PC it needs to check if where to start so the 5 text boxes are filled with the correct values. If I leave this line out: Serial.println ("\t "); it starts everytime after opening and closing the vb program it writes every time in a different box. But if I add it it will not read with the below vb code. So the code should search for the Tab and then display the next cyclus of data and put them in the text boxes. I have tried numerous things like treshhold higher but I got lost in the things. Any suggestion would be welcome
Private Sub Form_Load() With MSComm1 If .PortOpen Then .PortOpen = False .CommPort = 4 .Settings = "9600,N,8,1" .DTREnable = True .RTSEnable = True .RThreshold = 1 .SThreshold = 0 .PortOpen = True End With With Text1 .BackColor = vbWhite .Locked = True .Text = "" End With End Sub Private Sub MSComm1_OnComm() Static Buffer As String Buffer = Buffer & MSComm1.Input If InStr(Buffer, vbCrLf) Then Dim TempBuffer() As String TempBuffer = Split(Buffer, vbCrLf) If UBound(TempBuffer) >= 5 Then Text1.Text = TempBuffer(0) Text2.Text = TempBuffer(1) Text3.Text = TempBuffer(2) Text4.Text = TempBuffer(3) Text5.Text = TempBuffer(4) Dim I As Integer Buffer = "" 'cleanup the Static buffer For I = 5 To UBound(TempBuffer) - 1 'retain any extra data Buffer = Buffer & TempBuffer(I) Next I End If End If End Sub