日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

vbs脚本学习笔记

發(fā)布時間:2023/12/20 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 vbs脚本学习笔记 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

1.定義變量/常量

  • dim 定義變量
    dim var=1
  • const 定義常量
    const PI=3.14

2.注釋

  • rem

3.條件判斷

' 判斷輸入數(shù)是否大于1dim num num=int(inputbox("請輸入一個整數(shù)")) if num>1 then msgbox("大于1") elseif num<1 then msgbox("小于1") elseif num=1 then msgbox("等于1") end if

相等符號不是== 而是=

'輸入數(shù)字判斷對應(yīng)的星期 dim num num=int(inputbox("請輸入1-7中一數(shù)字")) select case num case 1 msgbox("MON") case 2 msgbox("TUE") case 3 msgbox("TUR") case 4 msgbox("WED") case 5 msgbox("FRI") case 6 msgbox("SAT") case 7 msgbox("SUN") case else msgbox("不在范圍內(nèi)") end select

4.循環(huán)語句

  • For…Next
'循環(huán)接收5個數(shù) 并計算其總和、平均值dim sum dim count count=5 dim i for i=1 to 5 step 1sum=sum+int(inputbox("第"&i&"個數(shù)")) next msgbox("總和:"&sum&" 絕對值:"&sum/count)
  • For Each…Next
' 循環(huán)輸入數(shù)組 并遍歷出來dim arr(4) dim i for i=0 to 4arr(i)=int(inputbox("請輸入數(shù)字")) Next For Each x in arrmsgbox(x) Next
  • Do…While Loop
'循環(huán)接收5個數(shù) 并計算其總和、平均值dim sum dim count count=0 dim i Do While count<5sum=sum+int(inputbox("第"&count+1&"個數(shù)"))count=count+1Loop msgbox("總和:"&sum&" 絕對值:"&sum/count)
  • Do Until…Loop

5.數(shù)組

  • 一維數(shù)組
    arr(4) 0-4 五個元素
  • 多維數(shù)組
    arr(2,4) 行0-2 列0-4 3*5=15個元素

6.函數(shù)

*自定義函數(shù)

function 函數(shù)名(參數(shù)1,參數(shù)2) 函數(shù)名=xxx//返回值類似于return end function 調(diào)用函數(shù) 1.call 函數(shù)名(參數(shù)) 2.函數(shù)名(參數(shù)) ' 計算數(shù)的平方function square(num) square=num*num end function dim num num=int(inputbox("輸入一個整數(shù)")) msgbox(square(num))
  • 常用內(nèi)建函數(shù)

7.子程序

  • 與函數(shù)區(qū)別 * 無返回值*
sub 子程序名end sub

w3c vbs教程

總結(jié)

以上是生活随笔為你收集整理的vbs脚本学习笔记的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。