MSComm control OnComm event triggered by chr(13)

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!
LongDaveAsked:
Who is Participating?
 
EDDYKTConnect With a Mentor Commented:
you need to take care from your code
0
 
PaulHewsConnect With a Mentor Commented:
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
0
 
LongDaveAuthor Commented:
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!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.