I think this is what you are looking for, if not please let me know
What I added is in Red.
VB Code:
Private Sub readFile() Dim blnStartReading1 As Boolean, blnStartReading2 As Boolean Dim strTestData As String Dim A As Integer Dim B As Integer Dim i As Integer Dim ii As Integer Dim strLatitude As String Dim strLongitude As String Dim strDepth As String ChDir App.Path Open strFilename For Input As #2 blnStartReading1 = False: blnStartReading2 = False While Not EOF(2) Line Input #2, strTestData If strTestData = "STOP" Then blnStartReading2 = False If blnStartReading1 = True And blnStartReading2 = True Then A = Len(strTestData) For B = 1 To A If Mid(strTestData, B, 1) = " " Then strLongitude = Mid(strTestData, 1, B - 1) strLatitude = Mid(strTestData, B + 1, A) Exit For End If Next B MsgBox " " & strLatitude & " " & strLongitude & " " & strDepth & "" [COLOR=Red]Open App.Path & "/NewFile.txt" For Append As #1 Print #1, " " & strLatitude & " " & strLongitude & " " & strDepth & "" Close #1[/COLOR] End If If blnStartReading1 = True And blnStartReading2 = False Then i = InStr(strTestData, "174=") ii = InStr(i + 1, strTestData, ";") If i < ii And i <> 0 Then strDepth = Mid(strTestData, i, ii - i) End If blnStartReading2 = True End If If strTestData = "EndHeader" Then blnStartReading1 = True If strTestData = "STOP" Then blnStartReading2 = False Wend Close #2 End Sub






Reply With Quote