I am having trouble figuring out how to save the contents of a textbos as a text file to a specific location without prompting the user. Can anyone help?
Printable View
I am having trouble figuring out how to save the contents of a textbos as a text file to a specific location without prompting the user. Can anyone help?
Does this help ?
Code:
Private Sub Command1_Click()
Open "c:\testfile.txt" For Output As #1
Print #1, Text1.Text
Close #1
End Sub
I think using FreeFile is a handy method for remembering filenumbers, this is especially handy with multiple files:
And yes Jbart I think it helps :) (are you dutch?)Code:Dim fn As FreeFile
Open "file" for output as #fn
Print #fn, text1.text
Close 'this will close all open files, if you use Close #fn it will only close this file.
Thanks Jop ! I keep forgetting about FreeFile. So far I have only written one program that needs multiple input and output statements for text files.
Not dutch, Texan. Have some Swiss roots from back in the 1800's though.
I think that helps... let me see what I can do with it.
:eek: EEK! :eek:
This is the correct code!Code:Dim fn As Integer
fn = FreeFile
Open "file" for output as #fn
Print #fn, text1.text
Close 'this will close all open files, if you use Close #fn it will only close this file.
With a little adapting it does what is required... thanks to all.