最好读到数组中先,数组可以是动态分配的。用Preserve
例如Dim strTxtFile() As String
Open "C:\1.txt" For Input As #1
While Not(EOf(1))
    ReDim Preserve strTxtFile(i)
    Input #1,strTxtFile(i)
    i=i+1
Wend
ReDim Preserve strTxtFile(i)
strTxtFile(i)="~~~Last~~~Line~~~String~~~"然后在Form_KeyPress中写(注意:Form的KeyPreView属性应设为True)
Private Sub Form_KeyPress(KeyAscii As Integer)
   Static i As Long
   If strTxtFile(i)="~~~Last~~~Line~~~String~~~" Then
        MsgBox "Show Done!"
   Else
        Text1=strTxtFile(i)
        i=i+1
   End If
End Sub
凭空写得,没有亲自试,wish.

解决方案 »

  1.   

    好像应该用 Line Input:Line Input #filenum, strLine
      

  2.   

    首先将  mainform 的 keypreview设为true,
    然后在mainform_onkeypress里加入对应的处理函数,
    先假定你已经打开了文件
    dim distext as string   '你要显示的行的内容
    dim myfile as string   '要打开的文件名
    dim  filehandle as long  '文件句柄
    filehandle=freefile
    myfile="c:\temp\test.txt"
    open myfile for input as #filehandle然后在keypreview中捕捉用户按的键
    if Keyascii=#13 then   '假设你要求用户按enter key继续
    if not eof(filehandle) then
    readnextline
    end 
    else
    msgbox("file is over")
    end if然后另外做一个函数,处理它
    private sub Readnextline
     lineinput #filehandle,distext
    end sub
      

  3.   

    string 本来就是一个动态字符数组,所以不必象iprogram那样一次就把所有内容全部读入,这样会浪费空间的
      

  4.   

    iprogram的方法是正确的,这样效率高
      

  5.   

    用line input才是好办法。和edyang的方法一样,每读一行指针就会自动跳到下一行,所以如果要按顺序读的话,每次都用这句是不会错的。