我想知道有多少程序员使用下面的方法(此任务的脏方法)
无论如何,它是有效的
- Sub test()
- ' define the first dimension of array approximately
- Dim ar(9999, 1)
- Dim i As Long, j As Long
- ' here you'll populate an array at runtime,
- ' as many as you need (of course you don't know how much)
- ' just for example
- For i = 0 To 333
- ar(i, 0) = i + 1: ar(i, 1) = i + 3
- Next
- ' declare the new hard bounded array instead
- ReDim newar(i - 1, 1)
- While Not IsEmpty(ar(j, 0))
- newar(j, 0) = ar(j, 0): newar(j, 1) = ar(j, 1)
- j = j + 1
- Wend
- ' return new array
- End Sub
顺便说一句,我也喜欢使用集合
~'J'~ |