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?
Love it! full commented so you get how to use it and learn
Code:
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
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET. subscribe