View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
RobertW RobertW is offline
external usenet poster
 
Posts: 3
Default Option Explicit and Arrays

There are two types of arrays(i.e. static and dynamic). A
static array is dim myarray(1 to 5). A dynamic array will
appear as dim myarray(). And then the code further down,
will show the redim statement specifying the parameters,
such as redim myarray (1 to foundfiles.count). The error
in your code below is that the redim refers to the wrong
letter (s/b n, not y) or that redim Y was not initalized
with dim y.

Robertw



-----Original Message-----
Just caught a typo.

In Excel 97 VBE, the following general module code

doesn't generate a compile
error.

'---- begin VBA ----
Option Explicit

Sub foo()
Dim n As Long
n = 5
ReDim y(1 To 5) '<- !!
MsgBox n
End Sub
'---- end VBA ----

Is the ReDim line an array variable declaration similar

to Dim, or a statement,
or a hybrid? Does this work the same in 2K and XP?

--
Never attach files.
Snip unnecessary quoted text.
Never multipost (though crossposting is usually OK).
Don't change subject lines because it corrupts Google

newsgroup archives.
.