请脚本编程高手帮个小忙,一个wsf的小程序,很急很急,在线等,标题搞长…………长一点吧……求大神帮助

我想统计TXT文本行数,然后网上有一小段程序,貌似vbs的,然后这段程序的结果输出在msgbox里,但是我要的数据很多,msgbox有个缺点就是不能把结果搞出来,我一个个... 我想统计TXT文本行数,然后网上有一小段程序,貌似vbs的,然后这段程序的结果输出在msgbox里,但是我要的数据很多,msgbox有个缺点就是不能把结果搞出来,我一个个手打要很久,所以请高手帮忙让结果输出在能CTRLc-CTRLv的地方! <job id="HowManyLines"> <script language="VBScript"> Const ForReading = 1 Dim objFSO, fold, f, strMsg, fileNames(100), objFile, lineCount(100),files,i set objFSO = CreateObject("Scripting.FileSystemObject") set fold = objFSO.GetFolder("C:\Documents and Settings\") set files = fold.Files For Each f in files If objFSO.GetExtensionName(f) = "txt" Then Set objFile = objFSO.OpenTextFile(f, ForReading) Do While objFile.AtEndOfStream <> True objFile.ReadLine lineCount(i) = lineCount(i) + 1 Loop objFile.Close fileNames(i) = f.Name i = i + 1 End If Next strMsg = "" For i = 0 To UBound(fileNames) If fileNames(i)<>"" Then strMsg = strMsg & fileNames(i) & ":" & lineCount(i) strMsg = strMsg & Chr(13) End If Next MsgBox(strMsg) </script> </job> 展开
 我来答
【冰泣】莽Fo35
2014-09-06 · TA获得超过116个赞
知道答主
回答量:112
采纳率:0%
帮助的人:107万
展开全部
On Error Resume Next Const ForReading = 1 Dim objFSO, fold, f, strMsg, fileNames(100), objFile, lineCount(100),files,i Dim Savename set objFSO = CreateObject("Scripting.FileSystemObject") set objWSH=createobject("WScript.Shell") set fold = objFSO.GetFolder( "C:\" ) set files = fold.Files For Each f in files If objFSO.GetExtensionName(f) = "txt" Then Set objFile = objFSO.OpenTextFile(f, ForReading) Do While objFile.AtEndOfStream <> True objFile.ReadLine lineCount(i) = lineCount(i) + 1 Loop objFile.Close fileNames(i) = f.Name i = i + 1 End If Next strMsg = "" For i = 0 To UBound(fileNames) If fileNames(i)<>"" Then strMsg = strMsg & fileNames(i) & ":" & lineCount(i) strMsg = strMsg & Chr(13) End If Next Savename = objFSO.GetFolder(".").Path & "\" Set txt=objFSO.opentextfile(Savename & "1.txt",8) txt.writeline vbcrlf & strMsg txt.close
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式