47147 网址导航 www.47147.com 精彩你所要 如果有什么问题请联系 qq:362650050 王先生
dim fname(5)......................................................................................................................................9
fname(0) = "George"..........................................................................................................................9
fname(1) = "John"..............................................................................................................................9
fname(2) = "Thomas".........................................................................................................................9
fname(3) = "James"............................................................................................................................9
fname(4) = "Adrew"...........................................................................................................................9
fname(5) = "Martin"...........................................................................................................................9
for i=0 to 5..........................................................................................................................................9
document.write(i & "<br />").............................................................................................................9
document.write(fname(i) & "<br />")................................................................................................9
next.....................................................................................................................................................9
</script>............................................................................................................................................10
</body>............................................................................................................................................10
</html>.............................................................................................................................................10
3、 表达式和运算符......................................................................................................................10
4、 常量...........................................................................................................................................11
什么是常数?..................................................................................................................................11
常数是具有一定含义的名称,用于代替数字或字符串,其值从不改变。VBScript 定义了许
多固有常数。详细信息,请参阅 VBScript 语言参考。.............................................................11
创建常数..........................................................................................................................................11
您可以使用 Const 语句在 VBScript 中创建用户自定义常数。使用 Const 语句可以创建名称
具有一定含义的字符串型或数值型常数,并给它们赋原义值。例如:..................................11
Const MyString = "这是一个字符串。".........................................................................................11
Const MyAge = 49...........................................................................................................................11
请注意字符串文字包含在两个引号 (" ") 之间。这是区分字符串型常数和数值型常数的最明
显的方法。日期文字和时间文字包含在两个井号 (#) 之间。例如:.......................................11
Const CutoffDate = #6-1-97#...........................................................................................................11
最好采用一个命名方案以区分常数和变量。这样可以避免在运行 Script 时对常数重新赋值。
例如,可以使用“vb”或“con”作常数名的前缀,或将常数名的所有字母大写。将常数和变量
区分开可以在开发复杂的 Script 时避免混乱。...........................................................................11
第二节 分支语句.............................................................................................................................11
1、 IF/THEN/ELSE 结构................................................................................................................11
条件语句..........................................................................................................................................11
经常地,当我们编写代码时,我们需要根据不同的判断执行不同操作。我们可以使用条件
语句完成这个工作。.......................................................................................................................11
在 VBScript 我们可以使用三种条件语句:................................................................................11
if 语句...............................................................................................................................................11
假如你希望在条件为 true 时执行一系列的代码,可以使用这个语句。.................................12
if...then...else 语句...........................................................................................................................12
假如你希望执行两套代码其中之一,可以使用这个语句。.....................................................12
if...then...elseif 语句.........................................................................................................................12
假如你希望选择多套代码之一来执行,可以使用这个语句。.................................................12
select case 语句................................................................................................................................12
假如你希望选择多套代码之一来执行,可以使用这个语句。.................................................12
如果对大家有所帮助希望能支持我的网站 www.47147.com 经常访问一下 最好设为首页且推荐给你的朋友