Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1720306
  • 博文数量: 171
  • 博客积分: 11553
  • 博客等级: 上将
  • 技术积分: 3986
  • 用 户 组: 普通用户
  • 注册时间: 2006-05-25 20:28
文章分类

全部博文(171)

文章存档

2012年(2)

2011年(70)

2010年(9)

2009年(14)

2008年(76)

分类:

2008-05-10 19:11:19

文件:repeat.zip
大小:0KB
下载:下载

'''本教程讲解了VBSciprt的循环控制语句的用法'''
'1.Do...Loop
'打印0-9数字
intCount = 0
Do While intCount < 10
    Wscript.echo intCount
    intCount = intCount + 1
Loop

intCount = 0
Do
    Wscript.echo intCount
    intCount = intCount + 1
Loop While intCount < 10

'2.Do...Until
intCount = 0
Do Until intCount = 10
    Wscript.echo intCount
    intCount = intCount + 1
Loop
'Do...Until的另一种写法
intCount = 0
Do
    Wscript.echo intCount
    intCount = intCount + 1
Loop Until intCount = 10

'3.Exit关键字的用法
Wscript.echo "Exit usage"
intCount = 0
Do
    Wscript.echo intCount
    intCount = intCount + 1
    If intCount > 5 Then Exit Do
Loop Until intCount = 10

'4.While...Wend用法
Wscript.echo "While...Wend"
intCount = 0
While intCount < 10
    Wscript.echo intCount
    intCount = intCount + 1
Wend
'5.For...Next用法
'For的作用范围[0,10]
Wscript.echo "For...Next"
intCount = 0
For intCount = 0 to 10
    Wscript.echo intCount
Next

'For的步距修改为2
intCount = 0
For intCount = 0 to 10 step 2
    Wscript.echo intCount
Next

'使用递减
intCount = 10
For intCount = 10 to 0 Step -1
    Wscript.echo intCount
Next

'6.使用For Each...Next
Dim dict
'创建一个字典对象
Set dict = CreateObject("Scripting.Dictionary")
'向字典中添加对象
dict.Add "0","Chinese"
dict.Add "1","English"
dict.Add "2","Janpaese"

For Each item in dict
    Wscript.echo dict.item(item)
Next

阅读(1065) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~