用vb如何实现 txt格式 转成 html格式
如何在 指定目录 生成新的HTML文件,请教大家指点
[解决办法]
一个例子:
Option Explicit
Private Sub TXT2HTML(ByVal sTXT As String, ByVal sHTML As String)
Dim iFileTXT As Long, iFileHTML As Long, sLine As String
On Error Resume Next
iFileHTML = FreeFile()
Open sHTML For Output As #iFileHTML
If Err.Number = 0 Then
iFileTXT = FreeFile()
Open sTXT For Input As #iFileTXT
If Err.Number = 0 Then
Print #iFileHTML, " <HTML> <BODY> "
Print #iFileHTML, " </BODY> </HTML> "
Do While Not EOF(iFileTXT)
Line Input #iFileTXT, sLine
Print #iFileHTML, " <P> " & sLine & " </P> "
Loop
Close #iFileTXT
End If
Close #iFileHTML
End If
On Error GoTo 0
End Sub
Private Sub Form_Load()
TXT2HTML "C:\1.txt ", "C:\1.HTML "
End
End Sub