READ a text file line by line and store it into string if a particular pattern is found ,then output the pattern into differnt string ?
Post your code.
How far you doing this.
Dim file_id As Integer
Dim strline As String
Dim array_item() As String
file_id = FreeFile
Open "D:\input.txt" For Input As #file_id
Dim i As Integer
i = 0
Do Until EOF(file_id)
Line Input #file_id, strline
ReDim Preserve array_item(i)
array_item(i) = strline
i = i + 1
so, What wrong with your code? any errors?
What you mean about "particular pattern"?
Post your text file sample.
to find the pattern just loop through your array with a for loop and compare the string with your pattern.
Try putting this in your loop:
If InStr(strline, "pattern", vbTextCompare) Then <do whatever you want with it here> end if
I think that will do away with the array then.
Dim FileNum As Integer
Dim DataLine As String
FileNum = FreeFile()
ctr = 13
Open "Directory\of\file.text" For Input As #FileNum 'Opening a text file using macro
While Not EOF(FileNum) 'check if end of file
Line Input #FileNum, DataLine ' read in data 1 line at a time
Dont forget to mark this solve your problem is solve.
thanks the problem has been solved