|
-
Aug 14th, 2000, 07:16 PM
#1
Thread Starter
New Member
From a beginner.
I am presented with a .txt file every month that contains a log of air-ground data communications between air traffic control and aircraft. The file is usually in the order of 5000 - 6000 pages. I am writing an application to make analysis easier. One task is to find where the ground system cancels the data link with a specific aircraft, which is characterised by the text line - CANCEL ALL CONTRACTS. I am able to extract each occurrence of this line and write it to a different file, however, the information that I really need (aircraft callsign and time stamp) occurs two lines earlier. How do I extract and add the previous 2 lines so that I write all three lines to the new file? I haven't tried an array as yet.
I use two Common Dialog Controls, one to select the file to read, the other to select the file to write and then the respective files are displayed in lblDataFile and lblFileWrite. I also use a text box (txtInput) to input the string that I am searching for.
Example of work so far:
Private Sub cmdSearch_Click()
Dim s1 As String
Dim s2 As String
Dim s3 As String
s1 = (lblDataFile.Caption)
s2 = (txtInput.Text)
s3 = (lblFileWrite.Caption)
'Open the file that data will be read from.
Open s1 For Input As #1
'Open or create write file.
Open s3 For Append As #2
Do While Not EOF(1)
Line Input #1, s1
If s1 = s2 Then Write #2, (s1)
Loop
'Close read file.
Close #1
'Close write file before reopening in another mode.
Close #2
'Displays message box when all required data is written to selected file.
MsgBox "Program has finished writing to file."
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|