当前位置:网站首页>Brief tutorial of vbs script syntax (1)
Brief tutorial of vbs script syntax (1)
2022-07-25 06:06:00 【N-order magic cube】
msgbox "Hello World!"
Msgbox grammar :msgbox " Content ", , " title "
2、 Input output interaction
Dim name
name= Inputbox(" Please enter your name :"," name ")
Inputbox(" Dialog content "," Dialog title ")
Msgbox name, , " What's your name "
3、 Variable definition and use
Vbs There is only one variable type , The system will automatically distinguish the variable type , And case insensitive .
Dim name,name2,............
Dim value
One 、 It is allowed to assign two variables simultaneously in one line of code , Separated by colons in the middle .Two 、、 You can use Option Explicit To tell the host that variables must be declared before being used .
3、 ... and 、、 Variable runtime type conversion .
Cbool Function converts a variable to a Boolean value ;
Cbyte The function converts a variable to 0 To 255 Integer between .
Ccur function 、Cdbl Functions and Csng Function converts a variable to a floating-point number , Ccur To four decimal places , The latter two are more accurate
Cdate Function converts a variable to a date value .
Cint Functions and Clng Function converts a variable to an integer , The scope of the latter is larger .
Cstr Function converts a variable to a string .
Four 、 Array
The subscript of an array always starts from 0 Start , Value minus one ends .
DIM array(9) // Define an array with ten data
value = array(4) // Access the fifth element
// Declare a dynamic array without specifying the number and dimension of the array .
// Use keywords redim To change the array .
// Be careful , When changing the size of the array , The data of the array will be destroyed , Use keywords preserve To protect data . for example :
RedIm Space preserve Space array Number of brackets comma dimension brackets
4、 The operator
operation : +,-,*,/, ^( chengfang ) , Mod( modulus )
Compare : = > < >= <= <> It's not equal to
Logic : AND NOT OR
Connection string :
+ or & ( In general use & The operator )
Comparison object :Is
5、 Conditional statements
---------------------
if Conditions then
......
......
else if Conditions then
......
......
endif
---------------------
Select case Variable
Case Conditional value
.......
Case Conditional value
.......
case else.......
nd select
---------------------
6、 Loop control statement
for……next loop
for……each loop
do……while loop
do……until loop
while loop
_____________________________________________________________________
Fixed number of times
For Counter variables = Start counting to Last count
Execution loop body
Next
_____________________________________________________________________
Array or object collection traversal
For each Loop count variable in Object or array to view
Execute processing statementsNext
Be careful : It can be used at any time in the above two cycles exit for To exit the loop
_____________________________________________________________________
Execute the loop when the conditions are met
Do while Conditions
Execution loop body
Loop
While Conditions
Execution loop body
Wend
_____________________________________________________________________
Execute the loop when the conditions are met
Do until Conditions
Execution loop body
Loop
Be careful : The above can be used exit do To exit the loop
7、 ... and 、 Use two processes
One is a function , Return value to caller
One is subroutine , No return value , There is also a special subroutine called event , Use less .
function
————————————————————————-----
Function The name of the function ( parameter list )
function code
The name of the function = Certain value ‘ Used to return the value
end function
Subroutines
————————————————————————-----
sub The name of the function ( parameter list )
function code
end sub
Be careful : When calling subroutines , The parameter list is not bracketed , Parentheses are only used in functions . in addition , Subroutines cannot be used in expressions . The function can only appear on the right side of the assignment statement , In the expression , Functions cannot be used directly , If you have to use functions directly , Must be used call The statement calls , And cancel the return value .
边栏推荐
- R language data The table package performs aggregation transforms of data packets and calculates the grouping interquartile range (IQR) of dataframe data
- Sword finger offer 54. the k-th node of the binary search tree
- PostgreSQL learning 04 PG_ hint_ Plan installation and use, SQL optimization knowledge
- [daily practice] day (14)
- (牛客多校二)G-Link with Monotonic Subsequence(构造题)
- Baidu, Alibaba, Tencent, who fell first?
- mysql数据库备份和恢复
- (Niuke multi school I in 2022) i-chiitoitsu (expected DP)
- 新时代生产力工具——FlowUs 息流全方位评测
- MySQL中建表时 pk、nn、qu、b、un、zf、ai、g代表的意思
猜你喜欢

Linear algebra (3)

(2022年牛客多校一)I-Chiitoitsu(期望DP)

In depth analysis: is the hottest business model in 2022 linked by 2+1 a legal model?

(牛客多校二)G-Link with Monotonic Subsequence(构造题)

Qunhui NPV Suite (NPV server) Download

Android interview question: why do activities rebuild ViewModel and still exist—— Jetpack series (3)

50 places are limited to open | with the news of oceanbase's annual press conference coming!

Req.body in node.express is always undefind

NFT: how to improve rentable NFT (erc-4907)

Xiaomi 12s UTRA Leica watermark generation online tool
随机推荐
10. Rendering Basics
深度解析:2022年最火的商业模式链动2+1,是合法模式吗?
Use abp Zero builds a third-party login module (4): wechat applet development
计算BDP值和wnd值
Android interview question: why do activities rebuild ViewModel and still exist—— Jetpack series (3)
Amazoncaptcha bypasses Amazon IP verification code with 95% success rate
新时代生产力工具——FlowUs 息流全方位评测
(14) [driver development] configuration environment vs2019 + wdk10 write XP driver
Linear algebra (3)
暑期总结2
"Everyday Mathematics" serial 61: March 1
PHP warehouse inventory management system source code WMS source code
同条网线电脑正常上网,手机连接wifi成功,但是无法访问互联网
R language obtains the data row where the nth maximum value of the specified data column is located in the data.table data
[typescript manual]
HTB-Arctic
Msys2 common configuration
HTB-Optimum
Big talk · book sharing | Haas Internet of things device cloud integrated development framework
What projects can make money online? Is it reliable to be we media?