I am having a strange problem on on the oncomm event.
In the oncomm I read each character 1 at a time and then load it into a buffer. When it reaches a vbcrlf it exits the loop and then outputs to a text box.
The issue is for some reason after its done that it goes back into the do/loop routine. When this happens, it drives the cpu load to 100% and eventually will generate a stack error (err 28)
Here is the code:
Private Sub MSComm1_OnComm()
On Error GoTo hell
x = 0
Do
c = MSComm1.Input
If InStr(a, vbCrLf) Then Exit Do
a = a + c
x = x + 1
If x >= 800 Then
Exit Do
End If
DoEvents
Loop
If Len(Text1.Text) > 5000 Then Text1.Text = vbNullString
a = Replace(a, vbCr, "")
a = Replace(a, vbLf, "")
If InStr(a, "*") > 0 Then
fonenum = Mid$(a, 34, 10)
End If
If Len(a) > 5 Then
Open "C:\SMDR\SMDR.LOG" For Append As #1
a = Trim$(a)
a = Replace(a, vbCrLf, "")
Print #1, a
Close #1
End If
If Len(a) > 0 Then Text1.Text = Text1.Text & a & vbCrLf
hell:
If Err > 0 Then
'Stop
Resume Next
End If
End Sub
In the oncomm I read each character 1 at a time and then load it into a buffer. When it reaches a vbcrlf it exits the loop and then outputs to a text box.
The issue is for some reason after its done that it goes back into the do/loop routine. When this happens, it drives the cpu load to 100% and eventually will generate a stack error (err 28)
Here is the code:
Private Sub MSComm1_OnComm()
On Error GoTo hell
x = 0
Do
c = MSComm1.Input
If InStr(a, vbCrLf) Then Exit Do
a = a + c
x = x + 1
If x >= 800 Then
Exit Do
End If
DoEvents
Loop
If Len(Text1.Text) > 5000 Then Text1.Text = vbNullString
a = Replace(a, vbCr, "")
a = Replace(a, vbLf, "")
If InStr(a, "*") > 0 Then
fonenum = Mid$(a, 34, 10)
End If
If Len(a) > 5 Then
Open "C:\SMDR\SMDR.LOG" For Append As #1
a = Trim$(a)
a = Replace(a, vbCrLf, "")
Print #1, a
Close #1
End If
If Len(a) > 0 Then Text1.Text = Text1.Text & a & vbCrLf
hell:
If Err > 0 Then
'Stop
Resume Next
End If
End Sub