Results 1 to 4 of 4

Thread: help to change code??

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2006
    Posts
    120

    Unhappy help to change code??

    VB Code:
    1. Private Sub Form_Load()
    2. Dim blnStartReading1 As Boolean, blnStartReading2 As Boolean
    3. Dim strTestData As String
    4. Dim A As Integer
    5. Dim B As Integer
    6. Dim i As Integer
    7. Dim ii As Integer
    8. Dim strLatitude As String
    9. Dim strLongitude As String
    10. Dim strDepth As String
    11. ChDir App.Path
    12.  
    13.  
    14. 'Open strfilename For Input As #2
    15. Open "test.txt" For Input As #2
    16.     blnStartReading1 = False: blnStartReading2 = False
    17.    
    18.     While Not EOF(2)
    19.         Line Input #2, strTestData
    20.         If strTestData = "STOP" Then blnStartReading2 = False
    21.        
    22.         If blnStartReading1 = True And blnStartReading2 = True Then
    23.             A = Len(strTestData)
    24.             For B = 1 To A
    25.                 If Mid(strTestData, B, 1) = " " Then
    26.                     strLongitude = Mid(strTestData, 1, B - 1)
    27.                     strLatitude = Mid(strTestData, B + 1, A)
    28.                     Exit For
    29.                 End If
    30.             Next B
    31.            
    32.         'MsgBox " " & strLatitude & " " & strLongitude & " " & strDepth & ""
    33.         Open App.Path & "/Data.txt" For Append As #3
    34.             Print #3, " " & strLatitude & " " & strLongitude & " " & strDepth & ""
    35.         Close #3
    36.  
    37.        End If
    38.                      
    39.         If blnStartReading1 = True And blnStartReading2 = False Then
    40.             i = InStr(strTestData, "174=")
    41.             ii = InStr(i + 1, strTestData, ";")
    42.                 If i < ii And i <> 0 Then
    43.                     strDepth = Mid(strTestData, i, ii - i)
    44.                 End If
    45.             blnStartReading2 = True
    46.         End If
    47.      
    48.       If strTestData = "EndHeader" Then blnStartReading1 = True
    49.       If strTestData = "STOP" Then blnStartReading2 = False
    50.      
    51.     Wend
    52. Close #2
    53. End Sub

    From the "text.txt" file,i only need the value inside "START 43, L, 174=0;133=300000" and "STOP" to change to the format below. By using the code above,i found mistake was happen(the blue color). i don't need to save the blue color value.
    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
    2.85667000 99.98843120 174=20
    2.85667000 99.70000000 174=20
    3.19926000 99.70000000 174=20
    3.73802000 100.94623000 174=20
    3.73897000 100.94658000 174=20
    3.74430000 100.94950000 174=20
    3.76365000 100.98286000 174=20
    Attached Files Attached Files
    Last edited by junlo; Feb 13th, 2007 at 05:12 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width