47147 网址导航 www.47147.com 精彩你所要 如果有什么问题请联系 qq:362650050 王先生
数组变量............................................................................................................................................8
有时,您需要向一个单一的变量赋于多个值。那么您可以创建一个可包含一系列值的变量 。
这种变量被称为数组。数组变量的声明使用变量名后跟一个括号 ()。在下面的例子中,创
建了一个包含三个元素的数组:.....................................................................................................8
dim names(2)......................................................................................................................................8
括号中的数字是 2。数组的下标以 0 开始,因为此数组包含三个元素。这是容量固定的数
组。您可以为数组的每个元素分配数据:.....................................................................................8
names(0)="George"............................................................................................................................8
names(1)="John"................................................................................................................................8
names(2)="Thomas"...........................................................................................................................8
同样地,通过使用特定数组元素的下标号,我们也可以取回任何元素的值。比如:...........8
father=names(0).................................................................................................................................8
您可以在一个数组中使用多达 60 个维数。声明多维数组的方法是在括号中用逗号来分隔
数字。比如,我们声明了一个包含 5 行 7 列的 2 维数组:........................................................8
dim table(4, 6)....................................................................................................................................9
实例....................................................................................................................................................9
创建变量............................................................................................................................................9
变量用于存储信息。本例演示如何创建一个变量,并为它赋值。...........................................9
<html>................................................................................................................................................9
<body>................................................................................................................................................9
<script type="text/vbscript">.............................................................................................................9
dim name............................................................................................................................................9
name="John Adams"..........................................................................................................................9
document.write(name)........................................................................................................................9
</script>..............................................................................................................................................9
</body>..............................................................................................................................................9
</html>...............................................................................................................................................9
在一段文本中插入变量值................................................................................................................9
本例为您演示如何在一段文本中插入变量值。...........................................................................9
<html>................................................................................................................................................9
<body>................................................................................................................................................9
<script type="text/vbscript">.............................................................................................................9
dim name............................................................................................................................................9
name="John Adams"..........................................................................................................................9
document.write("My name is: " & name)..........................................................................................9
</script>..............................................................................................................................................9
</body>..............................................................................................................................................9
</html>...............................................................................................................................................9
创建数组............................................................................................................................................9
数组用来存储一系列相关的数据项。本例演示如何创建一个存储名字的数组。(我们使用
"for loop" 来演示如何输出名字。)................................................................................................9
<html>................................................................................................................................................9
<body>................................................................................................................................................9
<script type="text/vbscript">.............................................................................................................9
如果对大家有所帮助希望能支持我的网站 www.47147.com 经常访问一下 最好设为首页且推荐给你的朋友