I'm trying to understand this OnComm event code. I'm using someone else's code and I need to know what it's doing. I do understand most of it but here's the questions I do have.
Why is stComChar declared with * 1 ?
A CommEvent must be capable of being events other than recieve events. In this code we only trap for the "comEvReceive" event, correct?
When the comEvReceive event fires, the incoming data is only 1 character? So we keep holding each character until a CR is detected?
After processing all incoming data, the InBufferCount is clear until another OnComm event is fired? Does the OnComm event (or shall we say the com device) send an InBufferCount every time it fires?
Private Sub comm1_OnComm()
Static stEvent As String 'storage for an Modem event
Dim stComChar As String * 1 'temporary storage for received comm port data
Select Case comm1.CommEvent
Case comEvReceive ' Received RThreshold # of chars.
stComChar = comm1.Input 'read 1 character .Inputlen = 1
Select Case stComChar
Case vbLf 'Ignore linefeeds
Case vbCr 'The CR indicates the end of the Receive String
If Len(stEvent) > 0 Then
ProcessEvent stEvent 'Process the Modem event
stEvent = ""
stEvent = stEvent + stComChar 'Save everything between CR's
Loop While comm1.InBufferCount 'Loop until all characters in receive buffer are processed