TA的每日心情 | 无聊 2018-9-27 10:05 |
---|
签到天数: 36 天 连续签到: 1 天 [LV.5]测试团长
|
回复 1# tianyinghua2012
我稍微修改了一下脚本,LZ你看一下吧- Dim FilePath
- FilePath = "D:\a.txt"
- Set fso=createobject("scripting.filesystemobject")
- If (fso.fileexists(FilePath)) Then
- msgbox "该文件存在",,"提示"
- else
- msgbox "该文件不存在",,"提示"
- Set WriteFile=fso.createtextfile(FilePath,2,False) '改了个参数
- WriteFile.WriteLine"abc"
- WriteFile.writeline"sdfsfsdf"
- WriteFile.writeline"今天天气很好"
- msgbox "写入文件成功",,"提示"
- WriteFile.close
- Set WriteFile = nothing
- End If
- Set ReadFile = fso.OpenTextFile(FilePath,1,False) '分开定义,
- set zsc=createobject("scripting.dictionary")
- do while ReadFile.atendofstream<>true
- line=line+1
- zsc.add line,ReadFile.readline
- '对话框显示
- msgbox "第" & line & "行: 【" & zsc(line) &"】内容"
- ' print ReadFile.readline
- loop
- '关闭文件
- ReadFile.close
- Set ReadFile = Nothing
复制代码 |
|