|
-
Sep 14th, 2004, 12:49 AM
#1
Thread Starter
New Member
reading .txt-file
Hey, I want to walk through a .txt-file line by line, for- and backwards. I want to do that using the fseek function I know from c/c++. How do I declare that function in vba? I know how to add and declare SendMessage, CreateFile and others but how can I do that with fseek?
Thanks,
Alex.
-
Sep 16th, 2004, 08:41 AM
#2
PowerPoster
Re: reading .txt-file
Originally posted by alexander_fleck
Hey, I want to walk through a .txt-file line by line, for- and backwards. I want to do that using the fseek function I know from c/c++. How do I declare that function in vba? I know how to add and declare SendMessage, CreateFile and others but how can I do that with fseek?
Thanks,
Alex.
you can open the file as binary and use Get to access a particular byte of data directly from the file.
as far as access in a line from a file with lines of varying length I dont know of a way to do that directly to/from the file. A good alternative is to read the file into a stringvariable then use:
Split(myString,vbcrlf) to get it into an array ... then you can access Line x directly from the array
myArray(x-1)
when you are done you just revers the procedure:
Join(myArray,vbcrlf) then write it back to the disc ...
-
Sep 17th, 2004, 07:35 AM
#3
Thread Starter
New Member
reading .txt file
Thanks,
I tried it and it works, but needs a lot of resources.
I now do it the old way, reading one line after the other. When I want to get the last line backwards I close the file, open it again and then read the lines until the chosen one is reached. It needs a lot of time, but doesn' t eat my memory. My application isn' t time related. It doesn' t matter if it needs more time, but my files are very big, because they offer measuring data.
Thanks,
Alex.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|