by BP (8 Submissions)
Category: Files/File Controls/Input/Output
Compatability: Visual Basic 3.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (5 Votes)
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")
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