Hi to all,
i've to parse a text file finding exactly some text in different lines.
For example:
file parse.txt
HATCH
5
A7122
330
309A6
100
AcDbEntity
8
QUOTE
62
1
100
AcDbHatch
10
0.0
20
0.0
30
HATCH
5
A7123
330
309A6
100
AcDbEntity
8
QUOTE
62
1 '<-I've to find this number
100
AcDbHatch
10
0.0
20
0.0
30
__________________
END OF FILE parse.txt
I would like to find the number after line with 62 (1) that is after this three lines
HATCH
5
A7123
I can read Lines from a txt file but i cant control the "next line parameter"
Start VBA CODE
Public Sub Parsedxf()
Dim sFileName As String
Dim iFileNum As Integer
Dim sBuf As String
Dim Fields As String
Dim TempStr As String
Dim strGenerator(0 To 3) As String
Dim i As Integer
i = 0
sFileName = "E:\Batch\parse.txt"
''//Does the file exist?
If Len(Dir$(sFileName)) = 0 Then
MsgBox ("Cannot find parse.txt")
End If
iFileNum = FreeFile()
Open sFileName For Input As iFileNum
Do While Not EOF(iFileNum)
Line Input #iFileNum, Fields
If Fields = "HATCH" Then
MsgBox (Fields)
End If
Loop
Close iFileNum
End Sub
End VBA CODE
The logic process that i would like to realize is:
Find "HASH"
if you find go to next line and find "5"
if you find go to next line and find "A7123" (if you dont find "A7123" then find "HASH" another time)
read the next line until reach "62"
go to the next line and manipulate "1" (for example replace 1 with a value in an excel cell)
Tips: the file that i've to parse have more than 6.000.000 rows so i have to find an efficient solution to manipulate le right row
Thanks in advance
Salmec
i've to parse a text file finding exactly some text in different lines.
For example:
file parse.txt
HATCH
5
A7122
330
309A6
100
AcDbEntity
8
QUOTE
62
1
100
AcDbHatch
10
0.0
20
0.0
30
HATCH
5
A7123
330
309A6
100
AcDbEntity
8
QUOTE
62
1 '<-I've to find this number
100
AcDbHatch
10
0.0
20
0.0
30
__________________
END OF FILE parse.txt
I would like to find the number after line with 62 (1) that is after this three lines
HATCH
5
A7123
I can read Lines from a txt file but i cant control the "next line parameter"
Start VBA CODE
Public Sub Parsedxf()
Dim sFileName As String
Dim iFileNum As Integer
Dim sBuf As String
Dim Fields As String
Dim TempStr As String
Dim strGenerator(0 To 3) As String
Dim i As Integer
i = 0
sFileName = "E:\Batch\parse.txt"
''//Does the file exist?
If Len(Dir$(sFileName)) = 0 Then
MsgBox ("Cannot find parse.txt")
End If
iFileNum = FreeFile()
Open sFileName For Input As iFileNum
Do While Not EOF(iFileNum)
Line Input #iFileNum, Fields
If Fields = "HATCH" Then
MsgBox (Fields)
End If
Loop
Close iFileNum
End Sub
End VBA CODE
The logic process that i would like to realize is:
Find "HASH"
if you find go to next line and find "5"
if you find go to next line and find "A7123" (if you dont find "A7123" then find "HASH" another time)
read the next line until reach "62"
go to the next line and manipulate "1" (for example replace 1 with a value in an excel cell)
Tips: the file that i've to parse have more than 6.000.000 rows so i have to find an efficient solution to manipulate le right row
Thanks in advance
Salmec