Open CommonDialog1.File For Input As #1
I = 0
Do Until EOF(1)
Line Input #1, Strs
I = I + 1
Loop
Close #1
MsgBox "站数是:" & I - 3这段代码只能计算一个文件有几行
我想把已经在(filelistbox)文件列表中的文件全部都计算出来要怎么写呢
Open Replace(File1.Path & "\" & File1.List(I), "\\", "\") For Input As #1

解决方案 »

  1.   

    谁帮我看一下错那里拉
    Dim I As Integer, j As Integer, G As Integer
    Dim fn As Long, strT As String, arr() As String
    For I = 0 To File1.ListCount - 1
        fn = FreeFile
        Open Replace(File1.Path & "\" & File1.List(I), "\\", "\") For Input As #fn
        G = 0
            Do Until EOF(1)
                Line Input #fn, strT
                G = G + 1
            Loop        Close #fn
        sh.cells(I + 1, 1) = G
       
        Next I
    ex.Visible = True
    End Sub
      

  2.   

    Dim I As Integer, j As Integer, G As Integer 
    Dim fn As Long, strT As String, arr() As String 
    For I = 0 To File1.ListCount - 1 
        fn = FreeFile 
        Open File1.Path & "\" & File1.List(I) For Input As #fn 
        G = 0 
            Do Until EOF(1) 
                Line Input #fn, strT 
                G = G + 1 
            Loop         Close #fn 
        sh.cells(I + 1, 1) = G 
        
        Next I 
    ex.Visible = True 
    End Sub
      

  3.   

    回LS:  Open File1.Path & "\" & File1.List(I) For Input As #fn  
      当 File1.Path 为根目录时,你这句会出错的!
    =======================================================回楼主:  你在2楼的代码,似乎没有什么错误呀!  如果有错误的话,最大的可能性是:G出现溢出!  要是你在运行时真的有什么错误,你不妨把具体的错误是什么、执行哪句时出错说一下,这样别人给你纠正起来就很容易。
      

  4.   

    我用Open Replace(File1.Path & "\" & File1.List(I), "\\", "\") For Input As #fn
    是溢出了
    我用Open File1.Path & "\" & File1.List(I) For Input As #fn   可以运行了
    thank you