Hi,
I have a text file in which the following line appears at irregular intervals:
Details For Earliest Pick Date : 21/11/06
After this line, records appear in tabular form until the above line appears with a different date on the end. What I want to do is take the date and place it at the end of every line and change it to the next date when it changes.
The code below works on text files where the first line is simply a date: 21/11/06. However, it does not work when the date is preceded by the 'Details for earliest pick date' text. How can I best adapt the code to work with the above scenario?
Dim InFile As Integer
Dim OutFile As Integer
Dim strOneLine As String
Dim strDate As String
InFile = FreeFile
Open "P:\TextFile.txt" For Input As #InFile
OutFile = FreeFile
Open "P:\TextFile2.txt" For Output As #OutFile
Do
Line Input #InFile, strOneLine
If IsDate(strOneLine) Then
strDate = strOneLine
Print #OutFile, strOneLine
Else
Print #OutFile, strOneLine, strDate
End If
Loop Until EOF(InFile)
Close #InFile
Close #OutFile
--
Thanks!
I have a text file in which the following line appears at irregular intervals:
Details For Earliest Pick Date : 21/11/06
After this line, records appear in tabular form until the above line appears with a different date on the end. What I want to do is take the date and place it at the end of every line and change it to the next date when it changes.
The code below works on text files where the first line is simply a date: 21/11/06. However, it does not work when the date is preceded by the 'Details for earliest pick date' text. How can I best adapt the code to work with the above scenario?
Dim InFile As Integer
Dim OutFile As Integer
Dim strOneLine As String
Dim strDate As String
InFile = FreeFile
Open "P:\TextFile.txt" For Input As #InFile
OutFile = FreeFile
Open "P:\TextFile2.txt" For Output As #OutFile
Do
Line Input #InFile, strOneLine
If IsDate(strOneLine) Then
strDate = strOneLine
Print #OutFile, strOneLine
Else
Print #OutFile, strOneLine, strDate
End If
Loop Until EOF(InFile)
Close #InFile
Close #OutFile
--
Thanks!