code below use to extract data from file(data.txt).now,i need to write the value strLatitude,strLongitude,strDepthto a new file and save it. How to write the code?
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 " " & [COLOR=Magenta]strLatitude[/COLOR] & " " & [COLOR=Magenta]strLongitude[/COLOR] & " " & [COLOR=Magenta]strDepth[/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