Results 1 to 3 of 3

Thread: Continually read serial port

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2001
    Location
    US Steel - Gary, IN
    Posts
    20
    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?

  2. #2
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Dunmow,Essex,England
    Posts
    898
    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.

  3. #3
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width