VBScript ArrayFunction
Complete VBScript Reference
The Array function returns a variable containing an array.
Note:The first element in the array is zero.
Syntax
Array(arglist)
| Parameter | Description |
|---|---|
| arglist | Required. A list of element values in the array (separated by commas). |
Examples
Example 1
<script type="text/vbscript">
a=Array(5,10,15,20)
document.write(a(3))
</script>
a=Array(5,10,15,20)
document.write(a(3))
</script>
The output result of the above example is:
20
Try it yourself »
Example 2
<script type="text/vbscript">
a=Array(5,10,15,20)
document.write(a(0))
</script>
a=Array(5,10,15,20)
document.write(a(0))
</script>
The output result of the above example is:
5
Try it yourself »
Example 3
Loop through all items in the array:
<script type="text/vbscript">
a=Array(5,10,15,20)
for each x in a
document.write(x & "<br />")
next
</script>
a=Array(5,10,15,20)
for each x in a
document.write(x & "<br />")
next
</script>
The output result of the above example is:
5
10
15
20
10
15
20
Try it yourself »
Complete VBScript Reference Other Extensions