當前位置:首頁 » 表格製作 » vbs動態數組怎樣循環添加元素
擴展閱讀
導航時怎樣調整方向盤 2024-11-25 18:27:51
自己可以弄短視頻嗎 2024-11-25 18:27:11
閑魚可以發布長視頻嗎 2024-11-25 18:14:21

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) 琛ㄧず鏁扮粍鍏冪礌鐨勬渶澶у簭鍙楓傚弬瑙侊細