-
Get current Line
I'm trying to read both binary and text information from a text file. The following code shows what I am doing but I need to be able to keep moving through the text. When I open for Input a second time I am reset to the first line of the text file. What can I throw in there to keep it moving along properly through each line of the text file without repeating lines? Also, I'm not sure if I am getting the proper line when I open for binary read. What can I put after "Get #1," to ensure I am getting the proper line?
Open SelectedFile For Input As #1
Do Until EOF(1)
If gettingPicture = True Then
Close #1
Dim mynewStrLine() As Byte
Open SelectedFile For Binary Access Read As #1
ReDim mynewStrLine(LOF(1))
Get #1, , mynewStrLine
gettingPicture = False
Close #1
Set picInsert(i) = LoadPicture(App.Path & "\myTempPic.txt")
Open SelectedFile For Input As #1
'(get onto proper line. How??)
Else
Line Input #1, strLine
GetField
If InStr(strLine, "End of Report:") > 0 Then
'this was the last line
Exit Do
End If
End If
Loop
-
Re: Get current Line
check out "Loc" and "Seek" in the help. perhaps you could do a loc before the first read, then when you reach your "getpicture" clause, close the file, re-open in binary, use seek to get to the previous loc, do your thing, record the new loc, close file, open for input, etc...
also, you could probably get away with not closing and re-opening the file all the time - just open it using two handles - #1, and #2.
-
Re: Get current Line
If I were doing this, I might store the length of the image data just before it, and once you read that line, you will know how much data to read. Another way might be to use a UDT, which could load various sorts of data all at once.