ben_Sewell_007
02-22-2004, 11:42 PM
ok the first thing. I am building a html code generator which is a freelance project for fun and it is my first sensible project (3 rubbish basic programs made). I get the users input and the user clicks on "Output now", which is a button. It generates the code, which is place in txtOutput. I want the ability to save the Output as a file.. prefebly if the user clicks on a button "save file" and then has to input a filename.. eg they type in "index" or "main". All files saved should be saved in the syntax "*.htm". Can anybody point a way to do this?
Ben
Use the CommonDialog controls. ShowSave Properties.
Dan_
malloc
02-23-2004, 12:37 AM
When you create an outputfile you can give it the extesion you want.
Open "output.htm" for output as #1
You could use a commondialog to let the user give the name of the file to create.
You can set the Filter property to something like:
CommonDialog1.Filter = "HTML files (*.htm)|*.htm"
Ej12N
02-23-2004, 12:41 AM
Love it! ;) full commented so you get how to use it and learn
Private Sub cmd_Click()
Dim Filename As String 'declare variable
On Error GoTo strCancel 'If the user press cancel goto strCancel
With CD ' CD = Commondialog name
.CancelError = True ' make an error if user press cancel
.Filter = "HTM Files *.htm|*.htm" 'Filter type of file
.ShowSave 'show the save dialog
Filename = .Filename 'this is the filename that the user gonna type
Open Filename For Output As #1
Print #1, txt.Text 'put what's on txt.Text to the user file *** in you case this would be txtOutput
Close #1 'save it =)
End With
strCancel: 'if cancel pressed then exit sub, so no file is created =)
End Sub