vb如何读取超长文本

来源:百度知道 编辑:UC知道 时间:2024/05/13 08:42:41
我自己试过 用这个读
Open "d:\3.txt" For Binary As #1
Dim b As Byte
While Not EOF(1)
结果什么也没读出来 我也不知道怎么回事
只要帮我写一条 可以将d:\3.txt 的所有文字+字符 读入 text1.text
的代码就好

'适用于任何文件
Open "d:\3.txt" For Binary As #1
Text1.Text = Input(LOF(1), #1)
Close #1

一次读完它!

'Form中放一个按钮和一个textbox

Private Sub Command1_Click()
text1 = ""
Open "d:\3.txt" For Input As #1
text1 = Input( LOF(1),1)
Close #1
End sub

Private Sub Command1_Click( )
Dim Lstr as String
Open "C:\\mytext.txt" For input As #1
Do While Not EOF(1)
Line Input #1, Lstr
Text1.Text = Text1.Text & Lstr & vbcrlf
Loop
Close #1
End Sub

在窗体上画一个文本框text1,一个按钮command1并把以上代码放入代码窗中

你把c:\\mytext.txt改成你要查看的文件名及路径。

点击按钮后文件内容即在文本框中出现

 代码:
Private Sub Command_Click()
Dim a As String

Open "C:\\mytext.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, a
Text1.Text=Text & a & vbCrLf
Loop