MSComm control OnComm event triggered by chr(13)

Posted on 2007-10-16
Last Modified: 2013-12-26
Using the MSCOMM control in VB6 (XP Pro) , is there any way to have the control generate the 'OnComm'
event when it sees a <cr>?  I would like to have it not generate commevent 2 until the entire line is read in.
Line lengths are variable, so I can't use a fixed length input. Thanks!
Question by:LongDave
    LVL 26

    Accepted Solution

    you need to take care from your code
    LVL 38

    Assisted Solution

    No this is not possible.  The technique you need to use is to store the incoming data in a string until the CR is detected:
    Private mstrIN As String

    Private Sub MSComm1_OnComm()
        If MSComm1.CommEvent = 2 Then
            mstrIN =mstrIN & MSComm1.Input
            If InStr(1, mstrIN, vbCr) Then
                '... handle the input here.
            End If
        End If

    Author Comment

    Thanks, guys - this is what I thought, but it's nice to have it verified. PaulHews - what you showed me
    is exactly the way I'm already doing it :-). I was just hoping there was the <cr> alternative possible.. Thanks again!

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
    A short article about a problem I had getting the GPS LocationListener working.
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now