想用vb打开一文本文件,逐行读出每一行
以下代码有什么问题,请指教:
set fso=createobfect("scripting.filesystemobject")
set ts=fso.opentextfile("c:\1.text")
do while not ts.eof
msgbox ts.readline
loop
do while not ts.eof这里老报错,说对象不支持的属性或方法,究竟判断文件结束的eof应该怎么使用啊?请指点,谢谢!
以下代码有什么问题,请指教:
set fso=createobfect("scripting.filesystemobject")
set ts=fso.opentextfile("c:\1.text")
do while not ts.eof
msgbox ts.readline
loop
do while not ts.eof这里老报错,说对象不支持的属性或方法,究竟判断文件结束的eof应该怎么使用啊?请指点,谢谢!
我不是很清楚
但我知道如果你使用工作区打开的open "c:\1.txt" for input as #1 do while not eof(1)
.............
loop
close #1但是这种读取方式要求文件不能大于64k的
希望能对你所帮助
Dim fso As New FileSystemObject
Dim ts As TextStream
Set ts = fso.opentextfile("c:\1.txt")
Do While Not ts.AtEndOfStream
MsgBox ts.readline
Loop
End Sub
MsgBox ts.readline
Loop
我试过,好象只能读出第一行,其它行不行也
我要读的文件很大了,有10m多的,原来我做过一个,可以的,不小心把原程序删了,只有exe文件在了,这次要做的功能上有所差异,但读文本文件这里是一样的,我记不到当时怎么用的了,痛苦啊!求到家帮帮忙啊,详细指点下.
MsgBox ts.readline
ts.skipline
Loop
Dim cxbl As String
Dim fso As FileSystemObject
Dim fil As TextStream
Const ForWriting = 8
Dim vstring As String
Set fso = New Scripting.FileSystemObject
Do While Not fil.AtEndOfStream
vstring = fil.ReadLine
loop
fil.close
Dim cxbl As String
Dim fso As FileSystemObject
Dim fil As TextStream
Const ForWriting = 8
Dim vstring As String
cxbl="c:\1.text"
Set fso = New Scripting.FileSystemObject
Set fil = fso.OpenTextFile(cxbl, ForReading, True)
Do While Not fil.AtEndOfStream
vstring = fil.ReadLine
loop
fil.close