2.如果要傳入陣列
那麼假設中間有個元素我不要 要怎麼剃除,讓後面的元素補上來?
假設是
Sub d()
Dim a
a = Array(1, 2, 3, 4, 5)
End Sub
如果3我不要 要怎麼剃除 讓後面補上 並且使陣列變小? 2維又是怎麼做?作者: luhpro 時間: 2014-11-4 23:19
Sub d()
Dim a, i, s
a = Array(1, 2, 3, 4, 5)
s = UBound(a) - 1
For i = 2 To s
a(i) = a(i + 1)
Next
ReDim Preserve a(s)
End Sub
多維陣列 的 列舉式賦值 我有看過這樣的:
Sub a()
Dim a, i, j, s1, s2
a = [{"a", 1, 2, 9; "b", 1, 3, 2; "c", 1, 4, 0; "d", 6, 7, 7; "e", 6, 7, 4}]
s1 = UBound(a, 2)
s2 = UBound(a, 1)
For j = 1 To s2
For i = 3 To s1 - 1
a(j, i) = a(j, i + 1)
Next
Next
ReDim Preserve a(s2, s1 - 1) ' 這行會發生錯誤
End Sub
但是增減維數會發生錯誤,
我還沒試出來該怎麼做.作者: kimbal 時間: 2014-11-5 00:52