一个TXT文件,分行写好,比如:aa
bb
cc
dd
……请问如何分行分别读出来?我的所有分数只有10分了,不好意思,希望能得到解答

解决方案 »

  1.   

    Private Sub File1_Click() 
    Dim nfile As String 
    Dim lstr As String 
    Text1.Text = "" 
    nfile = FreeFile 
    Open File1.Path & "\" & File1.List(File1.ListIndex) For Binary As nfile '打开指定的文件内容 
    Text1.Text = Input(LOF(nfile), nfile) 
    Close nfile End Sub
      

  2.   

    goldstar3000(蓝腾软件)你的代码不可用啊
      

  3.   

    以下代码保存为"ModReadTxtToStr.bas":'*************************************************************************
    '**模 块 名:ModReadTxtToStr
    '**说    明:读取文本文件内容到字符串
    '**创 建 人:马大哈
    '**日    期:2006年5月19日
    '**修 改 人:
    '**日    期:
    '**描    述:
    '**版    本:V1.0
    '*************************************************************************
    Option ExplicitPublic Function GetTxtToStr(ByVal TxtName As String) As String
        Dim I As String
        
        Open TxtName For Binary As #1
            I = Space(LOF(1))
            Get filenum1, , I
        Close #1
        GetTxtToStr = I
    End Function然后作这样的调用:dim I as string,J() as stringi=GetTxtToStr("1.txt")j=split(i,vbcrlf)J()里面就是你要的东西了从0开始
      

  4.   

    Dim nfile As integer 
    Dim lstr As String 
    nfile = FreeFile 
    Open "你哪个文件.txt" For input As nfile '打开指定的文件内容 do while not eof(nfile)
    line Input #nfile,lstr
    debug.print lstr
    loop
    Close nfile
      

  5.   


     filenum1 的变量是什么?有错啊....