Page 1 of 1

How to save the contents in a text box to a .txt file

Posted: Sun May 15, 2005 9:12 pm
by marcmarteleira
How to save the contents in a text box to a .txt file in a area of there computer that you get to choose, can any1 tell me how to do this kinda like this say your registering a product and u have to mail in the sheet so u type everything in u click the button and it saves the info in a txt file somewhere on your computer where u get to choose. How can i do so?

Posted: Mon May 16, 2005 12:44 pm
by Cheech|N|Chong
Type this in the command button (code):

(Change "Text1.Text" to the name of the textbox you have)

Code: Select all

Dim Text As String

Open "C:\Documents and Settings\All Users\Desktop\Sample.txt" For Output As #1
Text = Text1.Text
Print #1, "This is whats contained in the Text1.Text Textbox: " + Text

Close #1

intMsg = MsgBox("File sample.txt Written")

Posted: Mon May 23, 2005 11:13 pm
by Onetoomanysodas
Yeah but he's asking if you can change the location it saves. Setting the save location to the value of the text box doesn't work.

Posted: Wed Jun 22, 2005 9:09 pm
by TfAv1228
u would use 2 text opens and save with these one would have the location of the text file u want to move the other would have its contents



Save
_________________________

file = FreeFile
exe2 = example.Text
Open "C:\something.txt" For Output As #file
Print #file, exe2
Close #file

MsgBox "File Saved!", vbInformation, "Saved"


Open
______________________________________

file = FreeFile

Open "C:\something.txt" For Input As #file
exe2 = Input(LOF(file), 1)
Close #file

example2.Text = exe2