我用VB打开.S19文件 ,并把它显示在TEXT上,但由于.S19文件一般比较大,有1500-2000行,导致打开时间太长,而且text显示出来的数据不完整,老是只能显示1200多行,谁知道这两个问题怎么解决? CommonDialog1.CancelError = True
 On Error GoTo Errhandler
 CommonDialog1.ShowOpen sFile = CommonDialog1.FileName
    Open sFile For Input As #1
        Do Until EOF(1)
            Line Input #1, NextLine
            Text1 = Text1 & NextLine & vbCrLf
        Loop
    Close #1
    Exit Sub
Errhandler: Exit Sub

解决方案 »

  1.   

    你的文件并不大
    控件改用RichTextBox
    读文件用binary方式的get方法一次性读出..不要用字符串拼接..
      

  2.   


        dim s as string
        dim h as long
        h=freefile
        Open sFile For binary As #h 
            s=apace(lof(h))
            get #h,,s
        Close  
        RichTextBox.text=s
      

  3.   

    先谢谢3楼 这里有两个疑问
    freefile指的是什么
    apace这个函数是什么 能直接调用吗?
      

  4.   

    呵呵,是 Space() 吧?空格。
      

  5.   

    Dim strTmp As String, bytTmp() As ByteOpen "c:\1.txt" For Binary As #1
    ReDim bytTmp(LOF(1) - 1)
    Get #1, , bytTmp
    Close #1strTmp = StrConv(bytTmp, vbUnicode)'Text1.MultiLine = True
    'Text1.ScrollBars = 2 - Vertical
    Text1 = strTmp
      

  6.   


    sorry 笔误了
    apace --> space
    freefile 返回一个可open的文件号 
      

  7.   

    还有一种方法就是用FSO对象一次性读入文本框Text中,非常快!。 Option ExplicitPrivate Sub Command1_Click() '读入文件到文本框Text1中
            Dim FSO As FileSystemObject
            Dim cText As TextStream
            Set FSO = New FileSystemObject
            '加载文件c:\alldll.txt
            Set cText = FSO.OpenTextFile("c:\alldll.txt", ForReading, False, TristateUseDefault)
            Text1.Text = cText.ReadAll()
            Call cText.Close
    End SubPrivate Sub Form_Load()
            '注意文本框的 Text1.MultiLine = True
            Text1.Text = ""
    End Sub