Dimfso,TeSTFile
Setfso=CreateObject("ScrIPting.FilESystemObject")
Fori=1TO10
SetTestFile=fso.CreateTextFile("C:\hello"&i&".txt",Ture)
TestFile.WriteLine("Hello,World!")
TestFile.Close
Next
VBS创建单个文件,在按钮事件中却可以执行,为什么?
用的WICC6.0版本
Dimfso,TestFile
Setfso=CreateObject("Scripting.FileSystemObject")
SetTestFile=fso.CreateTextFile("C:\hello.txt")
问题补充:
WICC6.0VBS连续创建文件,在按钮事件中不执行,
在记事本程序创建后,却执行很顺利
程序如下:
Dimfso,TestFile
Setfso=CreateObject("Scripting.FileSystemObject")
Fori=1To10
SetTestFile=fso.CreateTextFile("C:\hello"&i&".txt",Ture)
TestFile.WriteLine("Hello,World!")
TestFile.Close
Next
WICC6.0VBS连续创建文件,在按钮事件顺利执行,
记事本程序创建后,执行顺利
修改后的程序如下:
Dimfso,TestFile,i
Setfso=CreateObject("Scripting.FileSystemObject")
Fori=1To10
SetTestFile=fso.CreateTextFile("C:\hello"&i&".txt")
TestFile.WriteLine("Hello,World!")
TestFile.Close
Next
这是为什么?记事本程序和wicc程序对VBS编程的要求不一样吗?
新手问题,多谢二位回答,没法都设为最佳答案,只能选择一位抱歉
最佳答案
是这段有问题
SetTestFile=fso.CreateTextFile("C:\hello"&i&".txt",Ture)括号里的字符串链接有问题。
这里改为("C:\hello"+i+".txt",Ture)看看,毕竟I是个数字。
提问者对于答案的评价:
谢谢您的回答