vb读取文本所有内容

来源:百度知道 编辑:UC知道 时间:2024/09/25 21:31:40
将C:\1.txt读取到text1

open 文件 然后do loop 然后连接数据赋值到text1

既然没分,那么只好说思路

dim fName as string
dim FileNum as long
dim strFile as string

fName="d:\test.txt"
FileNum=freefile
open fName for binary as FileNum
strFile=space(lof(FileNum))
get FileNum,,strFile
close
text1=strFile

如果文本文件中有回车,要设置text1的MultiLine为true

建Text1,代码如下。
==============
Private Sub Form_Load()
Open "c:\1.txt" For Input As 1
Text1.Text = StrConv(InputB(LOF(1), 1), vbUnicode)
Close
End Sub

open ............
write...........
close ..............
好像是这个 好久没玩了

看一下msdn的《文件》部分 没有就在网上下一个msdn for vb

用readline或其他都可以