If you are opening the file for binary access, then you can only retrieve chunks of data from the file, specified by the length of the string you declare. e.g.
Code:
Example 1:
Open "C:\Test.txt" for binary as #1
'Get all data in the file
strTemp = Space(LOF(1))
Get #1, , strTemp
Close #1
Example 2:
Dim strTemp as string * 10 '10 bytes
Open "C:\Test.txt" for binary as #1
'Get 1- bytes from start of file.
Get #1, , strTemp
Close #1
If you want to retrieve data from each line in your file (which it looks like you are trying to do), then you should use the following method.
Code:
'To read lines from a file, and append them
'to a string (with carriage returns at the end)
'use this method.
Open "C:\Test.txt" For Input As #1
'Loop while not the end of file
Do While Not EOF(1)
'Get a line form the file
Input #1, strTemp1
'Append it to the file
strTemp2 = strTemp2 & strTemp1 & vbCrLf
Loop
Or, if you are just after getting a big chunk from the file, use the following method.
Code:
'To retrieve a whole chunk from a file, use this method.
Open "C:\Test.txt" For Binary As #1
'Create a string buffer
strTemp1 = Space(LOF(1))
'Get the data from the file
Get #1, , strTemp1
Close #1
I hope this has helped. If you are still having problems, post back and explain in more depth what you are exactly trying to retrieve from the file...
Laterz
REM
