Top DevX Stories
Creating Custom Export Filters for StarOffice with XSLT
WPF Wonders: Using DataTemplates
Crystal Reports Family Offers Options for Developers
Avaya Aura Session Manager video
Avaya Aura Overview video
Search the forums:

Go Back   DevX.com Forums > DevX Developer Forums > VB Classic

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 11-05-2005, 02:08 PM
mp_direct mp_direct is offline
Registered User
 
Join Date: Nov 2004
Location: UK
Posts: 185
Unhappy Copying data from one txt file to another

Hi All,

My program is a questionnair where the user simply enters data like Title, Firstname, Surname etc. Once the user clicks on SAVE it outputs the data to a txt file.

The way it should work is each time a user clicks on SAVE, if the file "C:\Test1.txt" already exists, the file name is changed by inserting the SYS data/time, and a new text file is created "Test1.txt", which has all the previous data plus the new data just inputted by the user i.e. the most up-to-date version file.

The problem i am having is if the file exists and after it has renamed the file with SYS DATE/TIME, when creating the new "Test1.txt" file will ALL THE PREVIOUS data is lost and it simply displays the new data the user had just inputted.
Code:
If retval = fileName Then
    MsgBox "file already exists", vbCritical
    Name "c:\Test1.txt" As "c:\Test1_OLD_" & Format(Now, "yyyy-mm-dd HhNn") & ".txt"

End If

    Open "C:\Test1.txt" For Append As #1
    Write #1, txtTitle, txtFirstname, txtSurname

    Close #1
Any comments would be appreciated.
__________________
Thankyou
Reply With Quote
  #2  
Old 11-05-2005, 04:28 PM
mstraf's Avatar
mstraf mstraf is offline
Senior Member
 
Join Date: Nov 2003
Location: Alameda, CA
Posts: 1,648
if you rename the file, the original file is lost and thus there is nothing to append to.
Use CopyFile instead of Name
But sincerely, I do not see any reason to keep an old version of the file if you are just appending data to it. The previous file is just the new one less the last line...
Marco
__________________
"There are two ways to write error-free programs. Only the third one works."
Unknown
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Save a file using client-side javascript Anjana Web 5 05-27-2008 12:17 PM
Loading data from a file to text boxs mike_w VB Classic 2 05-22-2005 12:04 PM
Importing data.. sigh Dana Database 3 10-09-2000 06:13 PM
Creating a form that saves to a txt file vale ASP.NET 1 08-23-2000 08:36 PM
DTS - deleting a text file after importing the data... Paul Database 0 08-22-2000 11:54 PM


All times are GMT -4. The time now is 11:12 PM.


Sponsored Links



Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.