Board logo

标题: [求助]VBS问题 [打印本页]

作者: joyn     时间: 2008-6-3 19:20    标题: [求助]VBS问题

用VBS怎么反回一个TXT文件的行数.
作者: slore     时间: 2008-6-3 19:50
readline自己数……

readall后split……去数组上限
作者: joyn     时间: 2008-6-3 20:40    标题: [结]

thank you!

不过已结了~~我用的是     On Error Resume Next


On Error Resume Next
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("d:\11.txt", 1)
Do While True
        If 1 Then
                lines = objfile.ReadLine
                If Err.Number <> 0 Then
                         WScript.Echo "#"&Err.Number&Space (5)&"lines="&m
                         Err.Clear
                         Exit Do
                End If
               
                m=m+1
                                                  
        End If
Loop
        Set objfso = nothing


[ Last edited by joyn on 2008-6-3 at 09:03 PM ]
作者: sonicandy     时间: 2008-6-18 21:56
set fso = createobject("scripting.filesystemobject")
set stream = fso.opentextfile("d:\11.txt",1,false)
if not stream.atendofstream then
    content = stream.readall()
    linecount = ubound(split(content,vbcrlf)) + 1
else
    linecount = 0
end if
call stream.close
call msgbox(linecount)

[ Last edited by sonicandy on 2008-6-18 at 09:59 PM ]