Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting a line of text into a Text file using VB

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Does anybody know how to code a function to insert a line of text into a text file and then save the change. Im sure it can be done but don't know how.

Thanks
 
I do not know of any "insert" to a texct file. You can read the file, copy the input records to an output file while writing the new record to output at the appropriate (to you) place. Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Thanks for the reply. Those websites are excellent.

I thought TextStream objects could do this in VBA but it looks like I need to use VB.


Cheers

Frank
 
Hi,

The textstream object does not have an insert method. You can either use .READALL and use instr() to find where the insertion point is, rebuild the string, and output it.

If the textfile is composed of fixed length records you may open the file for random access and put the chunks back together.

Have a good one!
BK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top