mscomm rthreshold
Very strange,
This code works well, despite of your recommendation:
While bEndFlag = False
DoEvents
If UserForm1.MSComm1.InBufferCount > 0 Then
Buffer = UserForm1.MSComm1.Input
Ch = CByte(Buffer(0))
If (Ch >= 48) And (Ch < 58) Then
ADCCode = (10 * ADCCode) + Ch - 48
ElseIf Ch = 13 Then
ADCCode = ADCCode + 2
Events = Events + 1
Cells(1, 1) = Events
Cells(ADCCode, 1) = Cells(ADCCode, 1) + 1
ADCCode = 0
End If
End If
Wend
But the event-driven works much slower, and hangs at
much less input characters rate
Private Sub MSComm1_OnComm()
Static ADCCode As Integer
Static Ch As Byte
Static Buffer As Variant
Select Case MSComm1.CommEvent
Case comEvReceive
Buffer = MSComm1.Input
Ch = CByte(Buffer(0))
If (Ch >= 48) And (Ch < 58) Then
ADCCode = (10 * ADCCode) + Ch - 48
ElseIf Ch = 10 Then
Cells(1, 1) = ADCCode
Cells(ADCCode + 2, 1) = Cells(ADCCode + 2, 1) + 1
ADCCode = 0
End If
Case Else
End Select
End Sub
Please, can you explain this?
Thank you,
Varuzhan