网站首页  汉语字词  英语词汇  考试资料  写作素材  旧版资料

请输入您要查询的考试资料:

 

标题 用VBS将一篇txt后缀的内容保存为html格式
内容
    把txt文件托放到这个vbs上试一下,它会自动生成一个htm文件。需要修的地方说一下。
    do.vbs
    代码如下:
    'BY Coo_boi
    If WScript.Arguments.Count=0 Then WScript.Quit
    Dim fso,txt,htm
    txt=WScript.Arguments(0)
    Set fso=CreateObject("Scripting.FileSystemObject")
    Set htm=fso.CreateTextFile(txt&".htm",True)
    title=fso.GetFile(txt).Name
    title=Left(title,Len(title)-4)
    MsgBox title
    htm.WriteLine "<html>"
    htm.WriteLine "<head>"
    htm.WriteLine "<title>"&title&"</title>"
    htm.WriteLine "</head>"
    htm.WriteLine "<body>"
    htm.WriteLine "<h1>"&title&"</h1>"
    htm.WriteLine "<hr color=red>"
    For Each line In Split(fso.OpenTextFile(txt).ReadAll ,vbCrLf)
    htm.WriteLine line&"<br>"
    Next
    htm.WriteLine "</body>"
    htm.WriteLine "</html>"
    htm.Close
    WScript.Echo "将txt转换为html成功"
    将上面的代码保存为do.vbs,然后将1.txt托动到do.vbs上。即可将txt的内容生成为html格式,并且有换行效果。
随便看

 

在线学习网考试资料包含高考、自考、专升本考试、人事考试、公务员考试、大学生村官考试、特岗教师招聘考试、事业单位招聘考试、企业人才招聘、银行招聘、教师招聘、农村信用社招聘、各类资格证书考试等各类考试资料。

 

Copyright © 2002-2024 cuapp.net All Rights Reserved
更新时间:2025/5/19 1:02:46