[RESOLVED] Saving Textboxes as HTML
If I have three textboxes (Title, Year, and Runtime) how would I go about saving the info typed into the textboxes as html, just as if I would have if I would have done it in an HTML editor. I know basic html code and I would know how to do it in editor such as frontpage but I want to design a program where I can type in certain info and then save it as html.
I thank you for any help that you can give me. :)
Re: Saving Textboxes as HTML
If you certain about HTML content then simply "print" it to a file:
VB Code:
Open "App.Path & "\somefile.htm" For Output As #1
Print #1, Text1.Text
Close #1
Re: Saving Textboxes as HTML
an html file is just a text file with an html extension:
VB Code:
Open "C:\myhtmlfile.html" For Output As #1
Print #1, txtTitle.Text
' etc
Close #1
what are you trying to achieve? - do you mean converting RichTextBox editing to html code or something?
Re: Saving Textboxes as HTML
Basically all I have right now are three txtboxes not richtxtboxes and I want to save the info that I put in the textboxes into an html type format.
Re: Saving Textboxes as HTML
there's no such thing as an HTML file format - it's just a text file with plain text in it - and that text happens to be HTML code.
you could create a HTML file just by doing (in the same manner as the above examples)
VB Code:
Open "C:\myhtmlfile.html" For Output As #1
Print #1, "Hello"
Close #1
if you open it with a web browser then it'll show hello - if you want formatting then you'll have to write the full HTML code required for the page to the .html file. e.g.
VB Code:
Open "C:\myhtmlfile.html" For Output As #1
Print #1, "<center>Hello</center>"
Close #1
Re: Saving Textboxes as HTML
create a html file like you want manually in any editor, then open the file in your browser and View source, so you can just see the text, you can then create all that from code
another way you can do it, if you always want to create the same html file, is to use that file as a template, so you can open it in your program, and replace some bookmarks (placeholders) with your textbox.text, then close
Re: Saving Textboxes as HTML
I tried the code but it says bad file name or number on 2
VB Code:
Open "C:\myhtmlfile.html" For Output As #1
Print #1, txtTitle.Text
Print #2, txtYear.Text
Close #1
Re: Saving Textboxes as HTML
that's not the line number it's the number of the file you're printing to:
VB Code:
Print #1, txtTitle.Text
Print #1, txtYear.Text
Re: Saving Textboxes as HTML
Thank you everyone for your help, I think I'm starting to figure it out now.
Thank you again :bigyello: