View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
RB Smissaert RB Smissaert is offline
external usenet poster
 
Posts: 2,452
Default Speed of fixed array versus dynamic array

Not sure I get this. Look at this:

Sub test()

Dim i As Long
Dim arr() As String

arr = Split("a b c d", Chr(32))

For i = LBound(arr) To UBound(arr)
MsgBox arr(i), , i
Next i

ReDim Preserve arr(0 To 10)

For i = LBound(arr) To UBound(arr)
MsgBox arr(i), , i
Next i

End Sub


RBS


"Bob Phillips" wrote in message
...
Because the array is fixed, not pre-determined perhaps, but fixed, it
cannot flex as the code proceeds. That is what I understand by dynamic.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

"Rick Rothstein (MVP - VB)" wrote in
message ...
I'm not sure, then, that I understand your use of the word "building".
Why would something like this....

Dim Items() As String
Items = Split("One,Two,Three,Four", ",")

or this...

Dim Things() As Variant
Things = Array(1, 2, 3, 4)

not be considered building a dynamic array? As a side point, you
introduced the word "building"... the OP's original statement was

"Also, I have been using dynamic arrays but did not use Redim."

Rick




"Bob Phillips" wrote in message
...
I wouldn't call that building a dynamic array in either case.

"Rick Rothstein (MVP - VB)" wrote in
message ...
How did you build a dynamic array without using Redim?

You can use an assignment from the Split and Array functions, as well
the directly assigning another (already dimensioned) array, to do that.