我用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
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
控件改用RichTextBox
读文件用binary方式的get方法一次性读出..不要用字符串拼接..
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
freefile指的是什么
apace这个函数是什么 能直接调用吗?
ReDim bytTmp(LOF(1) - 1)
Get #1, , bytTmp
Close #1strTmp = StrConv(bytTmp, vbUnicode)'Text1.MultiLine = True
'Text1.ScrollBars = 2 - Vertical
Text1 = strTmp
sorry 笔误了
apace --> space
freefile 返回一个可open的文件号
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