读取文本的行,要求读取一行处理一行。
有回车换行符的用语句(line Input #)好读取,但有换行无回车的怎么读取我用的是vb6

解决方案 »

  1.   

    引用Microsoft Script RuntimeDim fsoTest As New FileSystemObject, file1 As File, ts As TextStream, s As String
    Set file1 = fsoTest.GetFile(“C:\testfile.txt")
    Set ts = file1.OpenAsTextStream(ForReading)
    Do While Not ts.AtEndOfStream
    '读取一行
    s = ts.ReadLine
    Debug.print s
    Loop
    ts.Close
      

  2.   

    上面的方法是一行一行地从txt文件中读取你可以参考:
    FSO使用http://web.jlnu.edu.cn/bdxy/webs/jiaocheng/vbjiaocheng/FSOdxmxvbz.htm
      

  3.   

    哟,mvp也来了,太感谢了。我说一下我的代码        Open "D:\test.txt" For Input As #1
                While NOT EOF(1)
                    Line Input #fp, strDataTmp
                   ......     '处理一行
                Wend
            Close #1
    这样,读取有换行有回车的行可以,读取有换行无回车的行却把整个文件都读进来了(把整个文件当成有换行有回车的一行了),如何解决?就得用fso么?