vb open语句问题!!!

来源:百度知道 编辑:UC知道 时间:2024/05/27 11:17:05
我现在在一个vb窗口里创建了一个text
在form load 里面输入如下代码
open "\1.txt" for input as #1
input #1,a
text1.text=a
close

为什么我运行后text里面只出现1.txt这个文本里内容的第一排

后面几排都不会出现

怎么弄??

'应该全文读入
open "\1.txt" for binary as #1
text1.text=input(#1,lof(1))
close 1

open "\1.txt" for input as #1
line input #1,a
text1.text=text1.text & a
close

因为你读了一次,没有循环到读完为止。
在Text1属性窗口把它的MultiLine改为True才分多行显示,否则会全部显示在一行中的。
Open "\1.txt" For Input As #1
Text1.Text = ""
Do While Not EOF(1)
Line Input #1, a
Text1.Text = Text1.Text & a
Loop
Close (1)