|
-
Jul 17th, 2010, 03:07 PM
#1
Thread Starter
Fanatic Member
Add text1.text into a .txt file
Hi guys,
Does anybody know how i can make it so that when a user writes some text in a text box and presses command1
then the text they entered will be added to a .txt file in the app directory and each item will be added on a new line.
For example if i type hello in text1
then it will add to a .txt file - hello
and then if i wrote goodbye it would add goodbye to the .txt file on a new line?
I hope this makes sense.
Thanks.
Jamie
-
Jul 17th, 2010, 03:10 PM
#2
Re: Add text1.text into a .txt file
Yes, Open the file for Append.
-
Jul 17th, 2010, 03:24 PM
#3
Thread Starter
Fanatic Member
Re: Add text1.text into a .txt file
Thanks,
Could you explain to me how to go about doing this? I don't understand what too do!
Cheers
Jamie.
-
Jul 17th, 2010, 03:30 PM
#4
Re: Add text1.text into a .txt file
Delete it. They just clutter threads anyway.
-
Jul 17th, 2010, 03:56 PM
#5
Fanatic Member
Re: Add text1.text into a .txt file
Code:
Dim iFileNo As Integer
Dim sFileText As String
Open App.Path & "\example.txt" For Append As #iFileNo
Print #iFileNo, text1.text
Close #iFileNo
Make sure that there is a text file called "example.txt" in with the application.
-
Jul 17th, 2010, 04:23 PM
#6
Thread Starter
Fanatic Member
Re: Add text1.text into a .txt file
thanks for the reply gamer, How ever i am having an error.
Saying bad file or number.
it then highlights - Open App.path & "\example.txt" For Append As #iFileNo
I have defo put a .txt file in the app directory called example.txt
What else could cause it to do this?
Thanks in advance,
Jamie
-
Jul 17th, 2010, 04:29 PM
#7
Fanatic Member
Re: Add text1.text into a .txt file
oh yeah. i fogot. after Dim sFileText as String, do
iFileNo = FreeFile
-
Jul 19th, 2010, 07:19 PM
#8
Thread Starter
Fanatic Member
Re: Add text1.text into a .txt file
Hi ya mate,
Sorry but at the moment it seems to be adding the things from the text boz that i add all on the same line in the .txt file.
Is there a way to make it so each time i press to command button it adds the textbox.text into the txt file but on a differant line?
Thanks.
-
Jul 19th, 2010, 07:21 PM
#9
Fanatic Member
Re: Add text1.text into a .txt file
It shouldn't do that with Append. Do you have Output instead?
-
Jul 19th, 2010, 07:56 PM
#10
Re: Add text1.text into a .txt file
The code that Gamemaster gave you in post #5 (with the small addition in post #7) works just fine. You obviously made no effort to try and join the two to make it work.
-
Jul 20th, 2010, 01:03 AM
#11
Addicted Member
Re: Add text1.text into a .txt file
Hi Jamie,
After modification, can you post your code here so someone can help you...
Regards
Veena
-
Jul 20th, 2010, 01:40 AM
#12
New Member
Re: Add text1.text into a .txt file
'if you use that code your need is ok.
Private Sub save()
Dim cfn, cf, fs
cfn = adress ' you will write here adress like that: c:/test.txt
Set fs = CreateObject("Scripting.FileSystemObject")
fs.DeleteFile cfn, True
Set cf = fs.OpenTextFile(cfn, 8, True)
cf.Write (Text1.Text)
cf.Close
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|