标题: [求助]请高手指点此代码为何不能生成bat文件
[打印本页]
作者: learner0
时间: 2008-4-22 23:24
标题: [求助]请高手指点此代码为何不能生成bat文件
On Error Resume next
Dim str1,str2,str3,cnt
str1="$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $"
str2="1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 1 2 3 4 5 6 7 8 9"
str3="@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @"
cnt=0
While cnt<4
cnt=cnt+1
str1=str1&vbCrLf&str2&vbCrLf&str3
Wend
Set cnt=Nothing
MsgBox str1,vbInformation,"vbscript application"
Set str1=Nothing
Set str2=Nothing
Set str3=Nothing
Call write_dat("e:\my.bat")
Sub write_dat(file)
Dim fso,a
Set fso=CreateObject("Scripting.FileSystemObject")
Set a=fso.CreateTextFile(file,0)
a.WriteLine("@echo off")
a.WriteLine("set str=@.I love you.@")
a.WriteLine("call :lab 14 500")
a.WriteLine("pause>nul")
a.WriteLine("goto :eof")
a.WriteBlankLines(2)
a.WriteLine(":lab")
a.WriteLine("for /l %%i in (1,1,%1) do set /p= %%str%:~%%i,1%<nul")
a.WriteLine("for /l %%j in (1,1,%2) do ver>nul")
a.WriteLine("goto :eof")
a.Close
Set a=Nothing
Set fso=Nothing
End Sub
作者: abcd
时间: 2008-4-22 23:31
可以啊。没什么问题
有问题也是在这里。
Set cnt=Nothing
Set str1=Nothing
Set str2=Nothing
Set str3=Nothing
非对象变量,不需要用set nothing
作者: learner0
时间: 2008-4-23 12:17
抱歉,偶没有电脑,很久没恢复帖子,谢谢指点,我弄懂啦,