Search Tools Links Login

Convert Text Document to HTML


Visual Basic 6, or VB Classic

This routine will allow you to convert any text document into an HTML document. This is a basic function that simply puts the template HTML tags into place and then adds line breaks after each line of the text file is read in. This would be handy function for converting large numbers of documents to web-format. This code would be used as following:
Call FileToHTML("c:autoexec.bat", "c: est.html", "Auto Execute File", "maroon", "white")

Original Author: Blake Pell

Code

Public Sub FileToHTML(InputFile As String, OutputFile As String, title As String, bgcolor As String, textcolor As String)
  newline$ = Chr$(13) + Chr$(10)
  Open InputFile For Input As #1
  Open OutputFile For Output As #2
  
  If title = "" Then title = "No Document Title"
  If bgcolor = "" Then bgcolor = "white"
  If textcolor = "" Then textcolor = "black"
  
  Print #2, "" + newline$
  Print #2, "" + newline$
  Print #2, "" + title + "" + newline$
  Print #2, "" + newline$
  Print #2, "" + newline$
  
  Do Until EOF(1)
    Line Input #1, myLine$
    Print #2, myLine$ + "
"
  Loop
  
  Print #2, newline$
  Print #2, "" + newline$
  Print #2, ""
  Close #1
  Close #2
End Sub

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 93 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.