|
-
Sep 2nd, 2006, 06:30 PM
#1
Thread Starter
Hyperactive Member
[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.
-
Sep 2nd, 2006, 06:35 PM
#2
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
-
Sep 2nd, 2006, 06:35 PM
#3
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?
-
Sep 2nd, 2006, 06:39 PM
#4
Thread Starter
Hyperactive Member
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.
-
Sep 2nd, 2006, 06:45 PM
#5
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
-
Sep 2nd, 2006, 06:58 PM
#6
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
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Sep 2nd, 2006, 07:08 PM
#7
Thread Starter
Hyperactive Member
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
-
Sep 2nd, 2006, 07:09 PM
#8
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
-
Sep 2nd, 2006, 07:31 PM
#9
Thread Starter
Hyperactive Member
Re: Saving Textboxes as HTML
Thank you everyone for your help, I think I'm starting to figure it out now.
Thank you again
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|