rem 定义和赋值数组
dim arr(3)
arr(0) = 20
arr(1) = 10
arr(2) = 25
arr(3) = 7
rem 定义索引
dim idx
rem 循环语句: for 变量 = 初始值 to 结束值 ... next
rem for i = 0 to 3
rem rem 内部可使用exit for结束循环
rem msgbox(arr(i))
rem next
rem 循环语句: for each 变量 in 集合 ... next
rem for each v in arr
rem rem 内部可使用exit for结束循环
rem msgbox(v)
rem next
rem 循环语句: do while 循环条件 ... loop
rem idx = 0
rem do while idx <= 3
rem rem 内部可使用exit do结束循环
rem msgbox(arr(idx))
rem idx = idx + 1
rem loop
rem 循环语句: do until 结束条件 ... loop
rem idx = 0
rem do until idx > 3
rem rem 内部可使用exit do结束循环
rem msgbox(arr(idx))
rem idx = idx + 1
rem loop
rem 循环语句: while 循环条件 ... wend
rem idx = 0
rem while idx <= 3
rem msgbox(arr(idx))
rem idx = idx + 1
rem wend
vbs教程《循环语句》
最新推荐文章于 2023-05-11 12:30:00 发布