Const ForReading = 1, ForWriting = 2
        Dim fso, f
        Set fso = CreateObject("Scripting.FileSystemObject")
        Set f = fso.OpenTextFile("c:\myasp\aa.txt", ForReading)
            ReadLineTextFile = f.ReadLine
            ReadLineTextFile = f.ReadLine
//////////////////文件只有一行内容,请问怎么解解决
输入超出文件尾

解决方案 »

  1.   

    Const ForReading = 1, ForWriting = 2
    Private Sub Command1_Click()
            Dim fso As FileSystemObject
            Dim f As TextStream
            Set fso = CreateObject("Scripting.FileSystemObject")
            Set f = fso.OpenTextFile("c:\myasp\aa.txt", , ForReading)
            Do While Not f.AtEndOfLine
                ReadLineTextFile = f.ReadLine
               Debug.Print ReadLineTextFile
            Loop
    End Sub
      

  2.   

    另一种办法.  我喜欢这样用.
    Dim FileNumber As Integer
    Dim FilePath As String, DataText As String......Open FilePath For Input As #FileNumber
    Input #FileNumber, DataText
      

  3.   

    另一种办法. 我喜欢这样用.
    Dim FileNumber As Integer
    Dim FilePath As String, DataText As String......Open FilePath For Input As #FileNumber
    Input #FileNumber, DataText
    //有些不会用,能不能照上面的代码改一下,谢了
      

  4.   

    使用AtEndOfLine 属性在 TextStream 文件中,如果文件指针正好在行尾标记的前面,那么该属性值返回 True;否则返回 False。同意楼上的楼上。
      

  5.   

    它不是有readall()的方法吗?
      

  6.   

    readall()
    或者侦测AtEndOfFile呗!
      

  7.   

    ReadLineTextFile = f.ReadLine
     ' 判断是否文件尾就可以了吧 不过是Eof(fso)还是fso.Eof我记不清了
    if(Not Eof(fso)) Then     
     ReadLineTextFile = f.ReadLine
    End if