Re: help to change code??
this code will open your file and read it all into memory to work on
VB Code:
Dim strfile As String, resarr() As String, i As Long, pos as long, pos1 as long
Open "test.txt" For Input As 1
strfile = Input(LOF(1), #1) ' read whole file
Close 1
pos = 1
Open "Data.txt" For Append As 1
Do
pos = InStr(pos + 1, strfile, "START 43, L, 174=") 'find start position
If pos = 0 Then Exit Do ' if no start position found finish
pos1 = InStr(pos + 1, strfile, vbNewLine) + 2
resarr = Split(Mid(strfile, pos1, InStr(pos1, strfile, "STOP") - pos1 - 2), vbNewLine)
' split the text in the lines between start and stop into an array
For i = 0 To UBound(resarr) ' process each line in array
pos1 = InStr(resarr(i), " ") + 1
resarr(i) = Mid(resarr(i), pos1) & " " & Left(resarr(i), pos1 - 2) _ 'swap order of line
& " " & Mid(strfile, pos + 13, InStr(pos + 14, strfile, ";") - pos - 13) ' add the 174 bit
Next
Print #1, Join(resarr, vbNewLine) ' print all lines in group to file
Loop
Close 1
Re: help to change code??
thanks westconn1.
but i still got problem, because my original file hv other format like below.It is not only format in blue color
START 43, L, 174=0;133=300000
3.85663000 100.81888000
.....
STOP
START 43, L, 133=250000;174=5
......
STOP
START 43, L, 133=250000;174=50;102="Approximate depth contour"
.....
STOP
START 43, L, 174=50
......
STOP
START 43, L, 174=100;133=300000
.....
STOP
Re: help to change code??
change the initial search string to find the start position so that it will work with all your strings,
i thought you only wanted to find the ones that had 174 = something so i searched upto the 174, if you want all values, just search to the "L"
if you need more help, give more examples of ones you want to include and ones you want to exclude, i only worked to the sample file you posted