本帖最后由 Tianorder 于 2016-8-15 15:10 编辑
回复 4# yu2n - Set fso = CreateObject("Scripting.FileSystemObject")
- Set ReadFile = fso.OpenTextFile("config.ini", 1, True)
- boolErr = false
- i = 0
- '循环文件,放入数组
- Do
- cha = ReadFile.ReadLine
- if Left(cha, 1) <> ";" and Left(cha, 1) <> "[" and cha <> "" Then
- ReDim Preserve arrDest(i + 1)
- arrDest(i) = cha
- i = i + 1
- End if
- Loop while ReadFile.atendofstream <> true
- x = ""
- count = UBound(arrDest)
- for i = 0 to count
- x = x & vbCrLf & arrDest(i)
- Next
- msgbox x
- ReadFile.Close
- Set fso = nothing
复制代码 我觉得并不是代码的错,就如1L所言,双击时是不会有问题的,但win计划任务会报错“输入超出了文件尾”。
把 while ReadFile.atendofstream <> true 放到do后面时,不会出现这个错误,但是会出现Ubound的错误。
把 while ReadFile.atendofstream <> true 放到do后面、不使用Ubound时,计划任务可以正常执行。 |