Rob,
I managed to distill the value into strValue
The code could be simplified? but it works for me.
I also have the newString containing the letter and seperator with value.
Stuck on the case select.
Watched several sample of case select but cant put my finger on it.
Paco
Private Sub MSComm1_OnComm()
Dim boComplete As Boolean
Dim intPos As Integer
Dim strValue As String
Dim strInput As String
Dim str() As String
Static strBuffer As String
Dim lngPos As Long
Dim lngPos2 As Long
Dim newString As String
Dim lngLen As Long
With MSComm1
'test for incoming event
Select Case .CommEvent
Case comEvReceive ' Something to receive
strInput = .Input
'strBuffer = strBuffer & strInput 'Receive it and add to our static Buffer
strBuffer = strInput 'Receive it and add to our static Buffer
Do
'
' Check if there's a complete record in the Buffer
' NOTE: This code assumes that the sender terminates
' each record with a Carriage Return Line Feed Pair
' If this is not the case then change vbCrLf below
' to whatever the terminator is
'
intPos = InStr(strBuffer, vbCrLf)
If intPos <> 0 Then
lngPos = InStr(strBuffer, vbCrLf) 'catch position number of first CRLF in the buffer
If lngPos > 0 Then newString = Left$(strBuffer, lngPos - 1) 'If the position is larger then 0 remove all rigth fromt the CRLF
lngPos2 = InStr(newString, ",") 'catch position number of the comma in the string
lngLen = Len(newString) 'measure length of string
If lngPos2 > 0 Then strValue = Right$(newString, (lngLen - 2)) 'remove the letter and the : from the string
Select Case (newString)
'Case A: TextSensorValue.Text = strValue
'Case B: TextStartSpeedValue.Text = strValue
End Select
str = Split(strInput, vbTab) 'debug line
Text9.Text = strInput 'debug line
' Check if there's anything else in the Buffer
'
If intPos + 1 < Len(strBuffer) Then
'
' Yes, move it to the front of the Buffer
' and go round the loop again
'
strBuffer = Mid(strBuffer, intPos + 2)
Else
'
' Nothing left in the Buffer
' Flush it and signal to exit the loop
'
strBuffer = ""
boComplete = True
End If
Else
'
' Haven't got a complete record yet
' exit the loop and wait for the next
' comEvReceive event
'
boComplete = True
End If