Vbs中If語句和Do
if true then 。.else 。.
------------------------------
if not true then 。.else。.
---------------------------------
if true then
。.
elseif true then
。.
elseif not then
。.
else
。.
end if
-------------------------------------
--------------------------------------
do
if true then exit do
loop
---------------------------------------
do while true
。.
loop
---------------------------------------
do
。.
loop while true
vbscript IF語句
我修改的代碼,測試通過,并能判斷是否數字形式。
<form name=validform>
<input name=t1 type=text size=5>
<input name=b1 type=button value="確定">
</form>
<script language="vbscript">
sub b1_onclick()
dim num
set num=*orm
if isnumeric(*) then
if *>=60 and *<=100 then
nums=1
elseif *>=0 and *<=59 then
nums=2
end if
select case nums
case 1
msgbox "及格"
case 2
msgbox "不及格"
case else
msgbox "輸入有誤"
end select
else
msgbox"請輸入一個數字"
end if
end sub
</script>
.vbs 怎么用if語句啊
因為是do loop 內的是死循環, 如果需要拷貝完就退出循環,可以加Exit do ,代碼修改如下
set fso=createobject("*stemobject")
on error resume next
do
if *xists("D:\") Then
*le "H:\*.doc","C:\新建文件夾"
exit do
end if
if *xists("G:\") then
*le "G:\*.doc","C:\新建文件夾"
exit do
end if
if *xists("I:\") then
*le "I:\*.doc","C:\新建文件夾"
exit do
end if
* 5000
loop
vbs if語句問題
親,不需要if *xists("H:\") then exit do 因為if *xists("H:\") then 為true才執行*le "H:\*.doc","C:\新建文件夾" 不存在就不執行
代碼如下:
set fso=createobject("*stemobject")
on error resume next
do
if *xists("D:\") Then
*le "H:\*.doc","C:\新建文件夾"
end if
if *xists("G:\") then
*le "G:\*.doc","C:\新建文件夾"
end if
if *xists("I:\") then
*le "I:\*.doc","C:\新建文件夾"
end if
* 5000
loop