当前位置:懂科普 >

综合知识

> vbs怎么写

vbs怎么写

1. vbs 怎么写

可以借助DOS命令来做,以下便是VBS代码,另存为test.vbs后运行测试。

vbs怎么写

'======================================================

Dim Command,Path

Path="F:media" '这里是文件夹路径

Command="setlocal enabledelayedexpansion"&vbcrlf&_

"set now=%date:~0,4%%date:~5,2%%date:~8,2%"&vbcrlf&_

"For /R "&Path&" %%i IN (*) Do ("&vbcrlf&_

" set tt= %%~ti "&vbcrlf&_

" set /a tt = %now%-!tt:~1,4!!tt:~6,2!!tt:~9,2!"&vbcrlf&_

" IF !tt! gtr 5 del /f /q %%~fi"&vbcrlf&_

")"

Set ws = createobject("wscript.shell")

ws.run Command,0

2. 我知道 VBS 怎么写 也知道是什么意思 但不知道 怎么运用 谁能指点下

a=inputbox("请输入名字",“输入”,"不死小强")

b=inputbox("请输入性别","输入","美女")

if b="美女" then

msgbox a &; "是" & b

else

msgbox a &; "是男的"

end if

for i=0 to 10 step 2

msgbox a & i

next

还有很多初级的应用,可以加入我们的VBS团队或QQ群

一定要有编程思想,判断循环是编程的基本思想,即便是C语,C++也会会用到,不懂这些,就和不懂一个样

3. 请问各位高手用VBS怎么写

可以提取后,用数组分开它们后,进行你需要的操作。

是做密码验证用吗?

vbs 代码如下:

Do

ww = 0

Do until mm = 1

xx = "1 2 3"

input = inputbox("本程序功能:"&chr(13)&chr(13)&;"输入一窜数字,求两两相乘后相加的结果。"&chr(13)&chr(13)&;"对话框内输入几个数字,并用‘ ’一个英文"&chr(13)&chr(13)&;"空格符将它们一一分开;例如: " & xx & chr(13)&chr(13)&;"点“取消”键,直接退出程序。"&chr(13)&chr(13),"提示:输入数字对话框",xx )

mm = 1

if input = "" then

wscript.Quit

end if

input = trim(input)

k = 0

for j = 1 to len(input)

if mid(input,j,1) = " " then

k = k +1

exit for

end if

next

if k = 0 then

msgbox "输入的内容少于2个! 请重新输入。",4144,"提示信息"

mm = 0

end if

BB = Split(input, " ")

FOR i = 0 to Ubound(BB)

if len(BB(i))0 and IsNumeric(trim(BB(i)))=false then

msgbox "输入的【 " & input &; " 】内有非数字内容,请检查后重新输入! ",4112,"提示信息"

mm = 0

exit for

end if

if len(BB(i))=0 then

msgbox "输入的【 " & input &; " 】内至少有两个“空格符”相连,请检查后重新输入! ",4112,"提示信息"

mm = 0

exit for

end if

next

loop

for ss = 0 to Ubound(BB)-1

for tt = ss+1 to Ubound(BB)

ww =ww+BB(ss)* BB(tt)

next

next

Response =msgbox ("输入的内容为:【 " & input &; " 】" & chr(13)& chr(13) &; "两两相乘总和 = " & ww & chr(13)& chr(13) &; "点击“是”则继续进行计算, " &chr(13)&chr(13)&; "点击“否”则直接退出程序!" ,4164,"提示:" &now)

mm = 0

loop Until Response = vbNo

4. 这段vbs怎么写

dim stre ,fs ,f1 ,f2 ,f3 '定义变量

Const ForReading = 1 定义常量

set stre=createobject("wscript.shell") '连接对象

set fs=createobject("scripting.filesystemobject") '连接对象

if msgbox ("你好!" ,vbokcancel ,"你好!") = vbok then '弹出对话框,进行选择,如果是确定,则运行以下操作。

Set f1=fs.OpenTextFile("D:123.txt" ,ForReading) '打开文件f3=f1.Readall '读取文件内容

f1.Close '关闭文件

msgbox f3 '显示文件内容

wscript.quit 退出

else 否则

set f2=fs.getFile("D:123.txt") 选中指定文件

f2.Delete 删除指定文件

wscript.quit 退出

end if

如果是要打开文件就用 “stre.run "notepad.exe D:123.txt" ”,

直接放到判断后就可以了。

标签: vbs
  • 文章版权属于文章作者所有,转载请注明 https://dongkepu.com/zonghezhishi/poyzmj.html