attiquesajid 0 Newbie Poster

Hi,
well i am pretty much new in visual basic and trying to get my hands onto this new thing.well i am reAding NMEA data from my serial port in vb6 using another computer that sends nmea data stored in a text file using hyperterminal(FILE ATTACHED).
right now i have written a sample code which is working fine most of the time but the problem is that my application must wait for the data to come form the other computer.if i send the file before i run the application, my program wouldn't read that data.
2nd thing is that the line code \\\\\strSentence = Mid(strInBuff, intStart, intFinish - intStart)\\\\\\\ in the following sample sometimes give me runtime error because of the negative value it gets........i don't know the reason why it gets this negative value.
SO
CAN I FIND SOMEBODY WHO CAN HELP ME OUT ON THIS??????

THE CODE IS AS FOLLOWS:
______________________________________________________
Private Sub Form_Load()
MSComm1.RThreshold = 128
MSComm1.InBufferSize = 1024
MSComm1.Settings = "4800,N,8,1"
' Open COM1
MSComm1.CommPort = 1
MSComm1.PortOpen = True
End Sub
______________________________________________________

Private Sub MSComm1_OnComm()
Dim strInBuff As String
Dim aryData(25)
Dim intLoop, intStart, intFinish, intString As Integer
Dim strSentence, strTemp, strDummy As String

Select Case MSComm1.CommEvent
Case comEvReceive
strInBuff = MSComm1.Input
For intLoop = 1 To Len(strInBuff)
If Mid(strInBuff, intLoop, 1) = "$" Then
intStart = intLoop
Exit For
End If
Next

For intLoop = intStart To Len(strInBuff)
If Mid(strInBuff, intLoop, 1) = vbCr Then
intFinish = intLoop
Exit For
End If
Next


strSentence = Mid(strInBuff, intStart, intFinish - intStart)
lblRCtime.Caption = strSentence
End Select
End Sub
____________________________________________________
Private Sub Form_Unload(Cancel As Integer)
MSComm1.PortOpen = False
End Sub

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.