2008年11月26日 星期三

VBScript - Array and Dynamic Array

' Array
array01 = Array("A","B","C")
For i = 0 To UBound(array01)
msgbox array01(i)
Next


' Split into Array
strary = "A,B,C"

array01 = split(strary,",")

For i = 0 To UBound(array01)
msgbox array01(i)
Next


' Dymanic Array
Dim ary()

reDim ary(1)

ary(0) = "一個"

msgbox(Ubound(ary))

msgbox(ary(0))

reDim ary(2)
ary(1) = "2個"
msgbox(Ubound(ary))
msgbox(ary(1))

'msgbox(ary(0))

' ReDim保留資料
ReDim Preserve ary(5)
msgbox ary(0)
msgbox ary(1)

沒有留言: