473,396 Members | 1,961 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

write to text file

The following code will "append" text to the END of the text file. How
can I add text to the beginning of a text file?

Dim fno As Integer

fno = FreeFile
Open "test.txt" For Append As #fno
Print #fno, "Hello World"
Close #fno

fno = FreeFile
Open "test.txt" For Append As #fno
Print #fno, "Hello World2"
Close #fno

Nov 13 '05 #1
3 14587
rc*********@yahoo.com wrote:
The following code will "append" text to the END of the text file. How
can I add text to the beginning of a text file?


To the beginning and leave the rest of the file intact? I think you'd have to
create a new file write the new data and then copy the data from the old file.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Nov 13 '05 #2
The text to be inserted at the beginning of the file is static text so
the "beggining" file (let's call it FileA) could already exist. If I
copy FileB to FileA will it insert all the text from FileB to the end
of FileA?

Nov 13 '05 #3

rc*********@yahoo.com wrote:
The text to be inserted at the beginning of the file is static text so the "beggining" file (let's call it FileA) could already exist. If I copy FileB to FileA will it insert all the text from FileB to the end
of FileA?


AFAIK, you can only insert at the end. So create a new text file, add
the header stuff, then copy the data from the old file. Save the new
file, delete the old one, and rename the new one. Just use the Name
function.

Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Google Mike | last post by:
I have PHP version 4.2.2 that ships with RH9. I want to have it write to a file like this: function WriteLog($sLogFile, $sMsg) { if (substr($sLogFile,1,1) != '/') { $sLogFile =...
5
by: Paul C-T | last post by:
Hi, Am I trying to be too clever here? I am trying to write a PHP page to enable me to enter values into a form then write those values to a text file. I want to use the form & table that...
1
by: Gurk | last post by:
hallow all i'm using a common dialog to save data into a text file. for so far i have this, but can someone give me a simpe exaple what i have to do after the line Open cdl.FileName For Output...
6
by: Suresh Kumaran | last post by:
Hi All, Does anybody know the sytax in VB.NET to write the contents of a multiline text box to a text file? Appreciate help. Suresh
6
by: Kevin Ingram | last post by:
Ok, this is probably a silly question but I just keep hitting a brick wall here. I usually develop my sites entirely in ASP and use a database for data storage, works great for me. I also...
13
by: Dan V. | last post by:
How do I create a one line text file with these control codes? e.g.: 144 = 0x90 and 147 = 0x93? I am trying to create a one line text file with these characters all one one row with no spaces. ...
1
by: WebSim via .NET 247 | last post by:
Hi, I want to read a text file, and then write it into dataset. Is it possible? or Is there any solution that read text file into DB? ----------------------- Posted by a user from .NET 247...
3
by: mainul | last post by:
Hi guys i can write text file and also can read it. below are the codes. <?PHP //write to a file $body_content="This is my content"; // Store some text to enter inside the file...
1
by: lokeshrajoria | last post by:
hello, how can i write text file text data to binary data in binary file. Thanks & Regards Lokiii
3
by: Pete Martinez | last post by:
Greetings, I need a simple method using ActiveXobject in javascript to write a text file from the local drive to my webserver. I found a method on a previous thread that copies a file from the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.