Article ID: 192012
Article Last Modified on 8/5/2004
Sub MSComm1_OnComm()
Static Buffer As String
' Always buffer incoming data no matter
' what generated the OnComm event.
Buffer = Buffer & MSComm1.Input
' Check if buffer has grown larger than limit.
If Len(Buffer) >= limit Then
' Call procedure to Process the received information.
process Left$(Buffer, limit)
' Clean-up buffer
Buffer = Right$(Buffer, Len(Buffer) - limit)
End If
End Sub
This procedure double-buffers the received data and, unless the program
is bound to fail because of some other performance problems, provides good
security for the received data. It is extremely important to handle every
character as it comes in at high baud rates. If you are looking for a
terminating character sequence instead of length, then the test would use InStr
instead of Len. 119591 How to Obtain Microsoft Support Files from Online Services
Additional query words: Wg1001
Keywords: kbinfo kbfile kbctrl KB192012