Scripting.FileSystemObject

XiaoBai2222 2004-07-30 05:15:32
Const ForReading = 1, ForWriting = 2
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("c:\myasp\aa.txt", ForReading)
ReadLineTextFile = f.ReadLine
ReadLineTextFile = f.ReadLine
//////////////////文件只有一行内容,请问怎么解解决
输入超出文件尾
...全文
243 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
csdnchenxu 2004-07-31
  • 打赏
  • 举报
回复
ReadLineTextFile = f.ReadLine
' 判断是否文件尾就可以了吧 不过是Eof(fso)还是fso.Eof我记不清了
if(Not Eof(fso)) Then
ReadLineTextFile = f.ReadLine
End if
Featured 2004-07-31
  • 打赏
  • 举报
回复
readall()
或者侦测AtEndOfFile呗!
dapha 2004-07-31
  • 打赏
  • 举报
回复
它不是有readall()的方法吗?
LGYAN 2004-07-30
  • 打赏
  • 举报
回复
使用AtEndOfLine 属性

在 TextStream 文件中,如果文件指针正好在行尾标记的前面,那么该属性值返回 True;否则返回 False。

同意楼上的楼上。
XiaoBai2222 2004-07-30
  • 打赏
  • 举报
回复
另一种办法. 我喜欢这样用.
Dim FileNumber As Integer
Dim FilePath As String, DataText As String

......

Open FilePath For Input As #FileNumber
Input #FileNumber, DataText
//有些不会用,能不能照上面的代码改一下,谢了
wj_1027 2004-07-30
  • 打赏
  • 举报
回复
另一种办法. 我喜欢这样用.
Dim FileNumber As Integer
Dim FilePath As String, DataText As String

......

Open FilePath For Input As #FileNumber
Input #FileNumber, DataText
northwolves 2004-07-30
  • 打赏
  • 举报
回复
Const ForReading = 1, ForWriting = 2




Private Sub Command1_Click()
Dim fso As FileSystemObject
Dim f As TextStream
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("c:\myasp\aa.txt", , ForReading)
Do While Not f.AtEndOfLine
ReadLineTextFile = f.ReadLine
Debug.Print ReadLineTextFile
Loop
End Sub

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧