473,385 Members | 1,872 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,385 software developers and data experts.

Append to a text file

I'm using this code for writing "hi" in a file

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2.   Open "c:\temp.txt" For Output As #1
  3.   Print #1, "hi"
  4.   Close #1
  5. End Sub
but I want that whenever I press command1 it writes "hi" there without overwriting the file.
Aug 18 '07 #1
4 1664
isn't here any1??????????????????????????????????????????????
Aug 19 '07 #2
kinnu
30
What you want to do ??? can u be clear in question?
Aug 19 '07 #3
Killer42
8,435 Expert 8TB
Two points...
  • Open for Append rather than Output.
  • Don't be impatient. The information on this site is provided by volunteers, who put in their own time when they can spare it. Plus, we live all around the world, in different timezones. So you can't always expect a quick response.
Aug 20 '07 #4
Another way!!!

In menu -> Project -> References -> Microsoft Scripting Runtime

Expand|Select|Wrap|Line Numbers
  1. Dim fso As New FileSystemObject
  2. Dim InStream As TextStream
  3.  
  4. Private Sub Command1_Click()
  5.  
  6.     InStream.Write ("hi")
  7. End Sub
  8.  
  9. Private Sub Form_Load()
  10. Set InStream = fso.OpenTextFile("<filename_path>", ForAppending, True)
  11. End Sub
  12.  
  13.  
Aug 20 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: gukn9700 | last post by:
The following program opens a text file and wants to append new text to it, but everytime I run it, it returns me with "open file fail!". Can anybody help? #include <fstream> #include...
2
by: sm | last post by:
How to "Insert" (not append) new text segment to an existing text file? Assume that we have text file as shown below; Elvis Sofia Kylix BCB--> How to insert here? Atten BuilderX Roma
3
by: Jonathan Buckland | last post by:
Can someone give me an example how to append data without having to load the complete XML file. Is this possible? Jonathan
0
by: | last post by:
Use the method InsertAfter() from the XmlDocument class or AppendChild from XmlNode class. Here is a short example to use InsertAfter(). http://weblogs.asp.net/sonukapoor/articles/132854.aspx ...
3
by: Craig.Lee | last post by:
I am opening a text file with an ODBC connection. I want to append all the text data to a table. Going row by row and field by field takes too long. Does anyone know how I can either reference the...
2
by: Roy Gourgi | last post by:
Hi, How could I append a text file to another text file. Let's say that I have a File1 and I want to append File2 at the end of File1, how would I do that? TIA Roy
3
by: Macca | last post by:
Hi, I am writing some information to a text file using the TextWriter Class. However I am having problems appending data to a file that already exists and already has text in it. I just seem...
2
by: Gaby Sandoval | last post by:
I have this code. The user can read teh record from the text file just fine. They can click the NEXT button and it reads the next record (which is just the next line from the text file). If the...
1
by: wish | last post by:
Hello, I have problem is when i append new data in text file always append at the last of the text file. Am i can append the new data in beginning of the text file? Mean when i have update data...
1
by: Deshi | last post by:
Hi,. I am trying to append text into the RTF file, nothing seems to be working for me... here is the code FileStream fs = new FileStream("c:\\djj.rtf", FileMode.Append, FileAccess.Write);...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.