Results 1 to 9 of 9

Thread: [RESOLVED] Saving Textboxes as HTML

  1. #1

    Thread Starter
    Hyperactive Member jlt7's Avatar
    Join Date
    Jan 2006
    Posts
    413

    Resolved [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.

  2. #2

  3. #3
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Saving Textboxes as HTML

    an html file is just a text file with an html extension:
    VB Code:
    1. Open "C:\myhtmlfile.html" For Output As #1
    2.     Print #1, txtTitle.Text
    3.     ' etc
    4. Close #1
    what are you trying to achieve? - do you mean converting RichTextBox editing to html code or something?

  4. #4

    Thread Starter
    Hyperactive Member jlt7's Avatar
    Join Date
    Jan 2006
    Posts
    413

    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.

  5. #5
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    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:
    1. Open "C:\myhtmlfile.html" For Output As #1
    2.     Print #1, "Hello"
    3. 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:
    1. Open "C:\myhtmlfile.html" For Output As #1
    2.     Print #1, "<center>Hello</center>"
    3. Close #1

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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

  7. #7

    Thread Starter
    Hyperactive Member jlt7's Avatar
    Join Date
    Jan 2006
    Posts
    413

    Re: Saving Textboxes as HTML

    I tried the code but it says bad file name or number on 2
    VB Code:
    1. Open "C:\myhtmlfile.html" For Output As #1
    2.     Print #1, txtTitle.Text
    3.     Print #2, txtYear.Text
    4. Close #1

  8. #8
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Saving Textboxes as HTML

    that's not the line number it's the number of the file you're printing to:
    VB Code:
    1. Print #1, txtTitle.Text
    2.     Print #1, txtYear.Text

  9. #9

    Thread Starter
    Hyperactive Member jlt7's Avatar
    Join Date
    Jan 2006
    Posts
    413

    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
  •  



Click Here to Expand Forum to Full Width