食品标注的内容:如何编写在VB中读取TXT文件的语句?

来源:百度文库 编辑:神马品牌网 时间:2024/05/01 19:55:14
谢谢

顺序访问方式
Dim Lstr as String
Open "C:\test.txt" For input As #1
Do While Not EOF(1)
Line Input #1, Lstr
Text1.Text = Text1.Text + Lstr
Loop
Close #1

二进制方式访问
Open "c:\test.txt" For Binary As #1
Text1.Text = Input(LOF(1), 1)
Close #1

希望你够了吧?

楼上的顺序访问有点慢,这样直接二进制读取会显示一点乱码。
其实这个东西,主要一句就可以的了。

Open "f:\d.txt" For Input As #1
text1.Text = StrConv(InputB$(LOF(1), 1), vbUnicode)
Close #1