The OP was asking (at least the way I read the question(!)) why I used:
Dim V as Variant
instead of
Dim V() as Long 'or variant or whatever.
Not exactly. The OP had posted this...
Dim KK(1 to 10) as double
You responded with this (note the parentheses on kk)...
dim kk() as variant
The OP then asked...
Is there a reason it has to be declared as a variant
To which I attempted to respond that the Variant (as opposed to any specific
data type such as Long) was required by the Array function and then I used
this example as a demonstration (note there are no parentheses on V) to show
that the Array function can return non-homogeneous data types requiring a
Variant to receive them...
Dim V As Variant
V = Array(123, "Text String", Range("A1"))
I think it is at this stage that I introduced some confusion into the
discussion. The interchangeability of these declarations...
Dim V As Variant
Dim V() As Variant
when what is being assigned to V is an array (the output from an Array
function being one such source) is clear in my own head and I never gave a
second thought that it might not be to others... I should have mentioned
something about it in my initial posting, but just didn't think to. You
eventually got me to do that, but it was like pulling teeth getting me
there<g... sorry.
Rick
"Dave Peterson" wrote in message
...
The Array function requires it. That is because you can put almost
anything
in the argument list to the Array function, as long as you remember what
is
what, of course.<g For example...
"Rick Rothstein (MVP - VB)" wrote:
<<snipped
But my real point to the OP was that some versions allow this syntax:
dim V() as variant
v = array(1,2,"A")
and some versions don't allow it.
This is because with the syntax shown, you are assigning an array
directly
to a dynamically declared array... the ability to do this was added in
Version 6 of VB/VBA.
Rick
--
Dave Peterson