-
What would be the best way to open a text file, find a string, delete it, perform an action then add the string back to the text file? !!!
ie
open text file
find "wibble"
if it exists - delete it
close text file
perform some action
open text file
add "wibble"
close text file
Any ideas people?
Simon
-
I didn't test it but try this out:
'This will open a file:
Open filename For Binary As #1
File = Space(LOF(#1))
Get #fnum, , filevar
Close #1
'And this will search it for the string and remove it:
a=instr(filevar,string)
filevar=left(filevar,a-1) & mid(filevar,a+len(string))
'This will put it back in the file
Open filename For Binary As #1
Put #1, , filevar
Close #1
'This will add string
Open filename for append as #1
Print#1, string;
close #1