How can I continually read the serial port via MSComm? The device I'm reading sends a message every second. I'd like to accept the data when it is being sent without using a timer. Can this be done?
Printable View
How can I continually read the serial port via MSComm? The device I'm reading sends a message every second. I'd like to accept the data when it is being sent without using a timer. Can this be done?
Just coding in the oncomm event should do it. Failing that it may be worth looking at the SAX Comm Object control that has a lot more events than the standard com control. I must admit I use this instead of the standard control and it's superb.
Juz loop till the MSComm1.InBufferCount = 0
Code:Option Explicit
Dim rdStr As String
Private Sub MSComm1_OnComm()
Select Case MSComm1.CommEvent
Case comEvReceive
rdStr = MSComm1.Input
Do While MSComm1.InBufferCount <> 0
rdStr = rdStr & MSComm1.Input
DoEvents
Loop
Case Else
End Select
End Sub