FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

VB 6.0 saving multipul .txt from a text box need help

 


andy26
ok so im going to make a timer and i want the contense from a text box to save as a .txt file but every 5 mins i want it to make a new txt file leaving the old one still there. so what i need is the code to save a .txt from a text box but to save it as a differnt .txt file each time leaving the old ones un overwrited.

Thanks in advance.
blueray
I try to help you.

    1.) define a form or global (module) variable to hold the file number
    2.) To create text file you have two options.
    i) using the standard open statement
    ii) using the filesystemobject from windows scripting hosting, add a reference to it by using the reference menu command.



Hope this help.
Trickster
If i'm right you might need some more detailed information about this.
First here is the code which will save a textbox to a .txt file:
Code:
PATH = (the directory where the file will be saved i.e.: App.Path & "\Data\")
TITLE = (name of your text file i.e.: log)
TEXT = (your textbox i.e.: Text1.Text)

Open PATH & TITLE & ".txt" For Output As #1
    Print #1, TEXT
Close #1


Second saving the next file with a new is a bit more complicated, but heres one way to do it:
Indstead of giving them a new name then make the title like this log1 log2 log 3 and so on.
Then you should make another txt file named fx File_name and then everytime you save a file name you take the last number and save it in the File_name.txt, so that everytime you save a new log, it starts off by reading through the File_name.txt and finds a number that has not been used yet. Then it takes that number and saves the log with that, and afterwards saving that new number in the File_name.txt to make sure you don't use that number twice and thereby overwrite an existing file with that number.
Reply to topic    Frihost Forum Index -> Scripting -> Others

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.