How would I be able to save whats in a textbox, to a text document?
eg: You click the save button, and a message pops up asking you what you want to name it, and then it saves in programs directory?
I would really appreciate the help thanks!
Printable View
How would I be able to save whats in a textbox, to a text document?
eg: You click the save button, and a message pops up asking you what you want to name it, and then it saves in programs directory?
I would really appreciate the help thanks!
1. put a cmdialog control on your form, name it cmd
2. make a commandbutton and a textbox
3. put this code in your form
4. pressing the button will now show up a savedialog and save it if you choose a correct name.Code:Private Sub Command1_Click()
dim ff as integer
On Error Resume Next
cmd.ShowSave
If Err Then Exit Sub
ff = FreeFile
Open cmd.filename For Binary As #ff
If Err Then Exit Sub
Put ff, , Text1
Close ff
End Sub
Kedaman, Why would you use Binary and not Output?
Code:Private Sub Command1_Click()
On Error Resume Next
commondialog1.ShowSave
Open commondialog1.filename For Output As #1
Print #1, Text1
Close #1
End Sub
[Edited by Matthew Gates on 07-03-2000 at 09:41 AM]
Is there a particular difference in this case?
Don't leave the cancelerror unhandled Matthew or you will save a file whether you press cancel or not.
Oops. That was just an example anyway Kedaman. I guess there is no difference. :)Code:If Err Then Exit Sub 'fixed