the code above use to retrieve data from file "test.txt" and then rewrite it to file "data.txt" in another kind of format like below.Code:Private Sub Form_Load() 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 Open "test.txt" 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 & "" Open App.Path & "/Data.txt" For Append As #3 Print #3, " " & strLatitude & " " & strLongitude & " " & strDepth & "" Close #3 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
3.85663000 100.81888000 174=0
3.85625000 100.81778000 174=0
3.85519000 100.80883000 174=0
3.20013000 101.29401000 174=20
3.20232000 101.29359000 174=20
3.20748000 101.29134000 174=20
i want stop to rewrite the data when the line context in file "test.txt" is "Start 302"




Reply With Quote