cosfreelance
MIS
Hi All,
I am reading a text file in to an array. the text file has 264 lines. The word REF, appears evey 66 lines (set to Jinf1)
What I am trying to do is read the array element index so i find the first appearence of the word REF. Should I remove the message box alert, the word REF is only picked up from the second occurance. Is there a reason for this?
I am unable to find the reason why it skips the first occurance and only works from the second appreance of the word. I am new to scripting and a bit stuck.. Any help would be sppreciated.
Dim arrSearchThis()
i = 0
Do While (l_textInput.AtEndOfStream <> True)
ReDim Preserve arrSearchThis(i)
arrSearchThis(i) = l_textInput.readline
If InStr(arrSearchThis(i), JInf1) Then
x = i
msgbox (x) ----------> this picks up the first REF occurance
End If
i = i +1
Loop
endline = UBound(arrSearchThis)
tmpline = ""
For newlines = x To endline -----------> Works only from the second occurance of the word REF
tmp = arrSearchThis(newlines) & vbNewLine
tmpline = tmpline & tmp
Next
msgbox (tmpline)
I am reading a text file in to an array. the text file has 264 lines. The word REF, appears evey 66 lines (set to Jinf1)
What I am trying to do is read the array element index so i find the first appearence of the word REF. Should I remove the message box alert, the word REF is only picked up from the second occurance. Is there a reason for this?
I am unable to find the reason why it skips the first occurance and only works from the second appreance of the word. I am new to scripting and a bit stuck.. Any help would be sppreciated.
Dim arrSearchThis()
i = 0
Do While (l_textInput.AtEndOfStream <> True)
ReDim Preserve arrSearchThis(i)
arrSearchThis(i) = l_textInput.readline
If InStr(arrSearchThis(i), JInf1) Then
x = i
msgbox (x) ----------> this picks up the first REF occurance
End If
i = i +1
Loop
endline = UBound(arrSearchThis)
tmpline = ""
For newlines = x To endline -----------> Works only from the second occurance of the word REF
tmp = arrSearchThis(newlines) & vbNewLine
tmpline = tmpline & tmp
Next
msgbox (tmpline)