我在将一个记事本文件里的内容读入程序中的Text时,如果记事本内容太多的话,读入很慢比直接复制粘贴还慢不少,有方法能快点吗?
我是这样写的
Do While Not EOF(1) ' 循环至文件尾。
Line Input #1, s
Text1.Text = Text1.Text & s & vbNewLine
Loop
Close #1
我是这样写的
Do While Not EOF(1) ' 循环至文件尾。
Line Input #1, s
Text1.Text = Text1.Text & s & vbNewLine
Loop
Close #1
楼主可以这样试试能不能稍快一点
先把文件内容赋给一个string
dim str_temp as string
Do While Not EOF(1) ' 循环至文件尾。
Line Input #1, s
str_temp = str_temp & s & vbNewLine
Loop
Close #1
Text1.Text =str_temp
一次次地做text赋值也是很慢啊
Open App.Path & "\test.txt" For Binary As #1
strTmp = Space(LOF(1))
Get #1, , strTmp
Close #1
Text1.Text=strTmp
Text1.Text = StrConv(InputB(LOF(1), 1), vbUnicode)
Close #1
northwolves(狼行天下)
的方法很快但text1.text显示的是乱码
laidon(走进.NET,开创新生活) 的方法仍旧很慢
我想读入正常的汉字啊
顺序文件读入能一次全读吗?
结果一次读入是正常的
一次汉字是乱码,字母正常
两次读入的都是txt文件,字体也一样。
Open "d:\xxxx.txt" For Binary As #1
Redim b(lof(1))
Get #1,,b
Close #1
Text1.Text = StrConv(b, vbUnicode)
erase b
Open "d:\xxxx.txt" For Binary As #1
Redim b(lof(1))
Get #1,,b
Close #1
Text1.Text = StrConv(b, vbUnicode)
erase b
------------------------------------------------------------
正解
如果是Ansi,用northwolves(狼行天下) 的方法
如果是Unicode,不需要StrConv转换
如果另存为“文本文档”或“MS_DOS 文本文档” 就能正常打开
另存为“Unicode 文本文档” 打开只有一个字而且是乱码。