README.md

December 5, 2022 · View on GitHub

Convert Text Document to HTML

Description

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:\test.html", "Auto Execute File", "maroon", "white")

More Info

Submitted On
ByBP
LevelIntermediate
User Rating4.2 (21 globes from 5 users)
CompatibilityVB 3.0, VB 4.0 (16-bit), VB 4.0 (32-bit), VB 5.0, VB 6.0
CategoryFiles/ File Controls/ Input/ Output
WorldVisual Basic
Archive File

Source Code

Public Sub FileToHTML(InputFile As String, OutputFile As String, title As String, bgcolor As String, textcolor As String) newline=Chr = 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, "<HTML>" + newline Print #2, "" + newline Print #2, "<TITLE>" + title + "</TITLE>" + newline Print #2, "" + newline Print #2, "<BODY bgcolor=" + bgcolor + " text=" + textcolor + ">" + newline Do Until EOF(1) Line Input #1, myLine Print #2, myLine + "
" Loop Print #2, newline Print #2, "</BODY>" + newline Print #2, "" Close #1 Close #2 End Sub