Locating cursor in text files in VB

M

Maya

How to get any required location in a text file in VB,to print certain contents
in specified location?

i=Loc(#1) gives the current location but while i do

seek #1,i
print #1,"Some data at specified location"

this print is getting printed in the text file at some position but not at
the place
where LOC is pointing. how to achieve this?

Im saving the text file as *.html to genearte html page in the end.
 
K

Karl E. Peterson

Maya said:
How to get any required location in a text file in VB,to print certain contents
in specified location?

i=Loc(#1) gives the current location but while i do

seek #1,i
print #1,"Some data at specified location"

this print is getting printed in the text file at some position but not at
the place
where LOC is pointing. how to achieve this?

Im saving the text file as *.html to genearte html page in the end.

If you opened the file for non-binary access (Input, Output, Append), you can't.
Only Binary supports writing (using Put) to specific locations in the file. And
then, of course, you're overwriting whatever's there. Random mode is not very
useful at all for the sorts of files you're using, either, so let's not even go
there.

The standard way for modifying a textfile is to read it entirely into memory, then
manipulating the content using native string functions (Mid, Instr, etc.). If this
isn't enough to get you going in the right direction, please let us know what you're
stumbling on.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top