我有一个文本文件但是要用VB把这个文件读出来条件是一行一行的读然后把它们赋给字符串型变量!
有那个高手知道

解决方案 »

  1.   


    '引用microsoft script runtime
        Dim I As Integer
        Dim str As String
        Dim fsoTest As New FileSystemObject, file1 As File, ts As TextStream
        Set file1 = fsoTest.GetFile("f:\test.txt")
        Set ts = file1.OpenAsTextStream(ForReading)
        Do While Not ts.AtEndOfStream
            str = ts.ReadLine
            Debug.Print str
        Loop
        Set ts = Nothing
      

  2.   

    Dim strx As String
    Open path + "tmp.txt" For Input As 1
    Do Until EOF(1)
        Line Input #1, strx
        ……
    Loop
    Close 1
      

  3.   

    Dim I As Integer
        Dim str As String
        Dim fsoTest As New FileSystemObject, file1 As File, ts As TextStream
        Set file1 = fsoTest.GetFile("f:\test.txt")
        Set ts = file1.OpenAsTextStream(ForReading)