标题:vb 怎么读写文本文件
取消只看楼主
zfjyyzycl
Rank: 2
等 级:论坛游民
帖 子:239
专家分:10
注 册:2006-4-15
结帖率:28.57%
 问题点数:0 回复次数:1 
vb 怎么读写文本文件
Private Sub CmdRead_Click()
Dim fsoTest As New FileSystemObject, file1 As File, ts As TextStream,
s As String
Set file1 = fsoTest.GetFile(“C:\testfile.txt")
Set ts = file1.OpenAsTextStream(ForReading)
'读取一行
s = ts.ReadLine
MsgBox s
ts.Close
End Sub


Private Sub CmdWrite_Click()
Dim txtfile As File, ts As TextStream
Set txtfile = fsoTest.GetFile(“c:\testfile.txt")
Set ts = txtfile.OpenAsTextStream(ForWriting)
'使用Write方法写入一行。
ts.Write (“This is only a Test")
' 写入一行带有换行符的文本。
ts.WriteLine (“Testing 1, 2, 3.")
' 向文件中写入三个换行符。
ts.WriteBlankLines (3)
ts.Close
End Sub

上面这段代码我在执行的时候 点击 CmdWrite_Click,系统就说 编译错误 用户定义类型未定义,错误停留在
Dim txtfile As File 这一行
如果点击 CmdRead_Click 系统就说 编译错误 用户定义类型未定义,错误停留在
Dim fsoTest As New FileSystemObject 这一行,是怎么回事啊
搜索更多相关主题的帖子: 文本文件 Set Sub txtfile fsoTest 
2006-11-16 01:08
zfjyyzycl
Rank: 2
等 级:论坛游民
帖 子:239
专家分:10
注 册:2006-4-15
得分:0 
怎么引用哈,请帮忙指点
2006-12-12 22:44



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-103291-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.294365 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved