GZ
我只知道一行一行的读,用个变量来记录。

解决方案 »

  1.   

    VB 高手都去那了???????????????
      

  2.   

    文本文件第一行写如下面的行数
      

  3.   

    Option ExplicitPrivate Sub Form_Load()
    Debug.Print TextFileLines("c:\autoexec.bat")
    End SubFunction TextFileLines(strFile As String)
    Dim s As String
    Dim b() As Byte
    Dim fh As Long
    fh = FreeFile
    Open strFile For Binary As fh
    ReDim b(LOF(fh))
        Get fh, , b
    Close #fhIf b(0) = 255 And b(1) = 254 Then  '(Unicod 文本文件)
        s = b
    Else                                '(ANSI 文本文件)
        s = StrConv(b, vbUnicode)
    End If
    TextFileLines = Len(s) - Len(Replace(s, vbCr, "")) + 1
    End Function