中国DOS联盟论坛

中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --
联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
游客 | 登录 | 注册 | 会员 | 搜索 | 中国DOS联盟
中国DOS联盟论坛
现在时间是 2026-08-08 06:49
48,041 主题排行 / 350,128 发帖 / 今日 3 篇 / 48,253 会员排行
DOS批处理 & 脚本技术(批处理室) » [求助]请高手指点此代码为何不能生成bat文件
可打印版本  725 / 2
第1楼 learner0 发表于 2008-04-22 23:24
初级用户 发帖 49 积分 108
[求助]请高手指点此代码为何不能生成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
第2楼 abcd 发表于 2008-04-22 23:31
银牌会员 发帖 739 积分 1,436
可以啊。没什么问题

有问题也是在这里。

Set cnt=Nothing
Set str1=Nothing
Set str2=Nothing
Set str3=Nothing

非对象变量,不需要用set nothing
第3楼 learner0 发表于 2008-04-23 12:17
初级用户 发帖 49 积分 108
抱歉,偶没有电脑,很久没恢复帖子,谢谢指点,我弄懂啦,
[ 联系联盟系统管理团队 - 中国DOS联盟 - 标准版 ]
Sponsored by ifanr Inc | © 2001–2023