Click to See Complete Forum and Search --> : writing to a file


Sir Static
August 8th, 1999, 06:14 PM
I was playing with VB and desided to figure out how to write to a file (so i could save the high scores on this game i made..). I used the write function but then when i looked at the file all the strings where enclosed in quotes. Could anyone tell me how to get it to write to a file and not print the quotes?

Another thing that i was wondering is how to write to a line in the midle of a file (eg. line 5) w/o having to rewrite the entire thing?

Ravi Kiran
August 8th, 1999, 07:44 PM
You can use Print #filenumber statement for writing the Text/Ascii info.

As for replacing a section of the file, i think the only way is to read the full file into a buffer, modify portions of it and write back the full buffer in one go. Otherwise when ever you modify a particular line, info after that line would be erased.

However, you could change the file format to INI type and replace select key data with WritePrivateProfileString etc.

VB also supports Text file type databases. May be this also you can use, to change select records. I dont exactly know how to....

RK