当前位置:首页 » 表格制作 » vbs动态数组怎样循环添加元素
扩展阅读
如何化妆可以使鼻子变高 2024-11-26 20:38:46
极米可以装手机APP吗 2024-11-26 20:25:37

vbs动态数组怎样循环添加元素

发布时间: 2024-04-15 07:31:09

Ⅰ VBS锷ㄦ佹暟缁勭殑闂棰

i = 0: nStr = ""
Dim MyArray()
Do
a = InputBox("寰鐜鐩村埌杈揿叆4涓烘")
ReDim Preserve MyArray(i)
MyArray(i) = a
i = i + 1
Loop Until a = "4"
For i = 0 To UBound(MyArray)
nStr = nStr & MyArray(i) & ","
Next
MsgBox nStr

琛ュ厖锛--------------------------------------
涓崭竴瀹氲 redim 钖庢墠鑳界粰鏁扮粍璧嫔
Dim MyArray(5)
MyArray(0)=455
MyArray(1)=500
.......
锲犱负杩欐椂鏁扮粍涓宸叉湁鍏幂礌 0 鍒 5 鍙

涓嬮溃镄勭敤娉曞氨蹇呴’ redim 钖庢墠鑳界粰鏁扮粍璧嫔
dim MyArray()'瀹氢箟锷ㄦ佹暟缁勶纴姝ゆ椂鏁扮粍涓涓涓鍏幂礌閮芥病链
ReDim Preserve MyArray(3)'閲嶅畾涔夋暟缁勭殑鍏幂礌 涓 0 鍒 3 鍙
MyArray(0)=455
MyArray(1)=500
MyArray(2)=2
MyArray(3)=78

For i = 0 To UBound(MyArray)
nStr = nStr & MyArray(i) & ","
Next
琛ㄧず锛氩皢鏁扮粍镄勬墍链夊厓绱犵敤瀛楃︿覆褰㈠纺杩炲湪涓璧凤纴鐢ㄢ,钬濆垎闅旓纴渚夸簬鏄剧ず銆
UBound(MyArray) 琛ㄧず鏁扮粍鍏幂礌镄勬渶澶у簭鍙枫傚弬瑙侊细