I am not sure I understand your point. Are you saying you think I should be
declaring V as a dynamic array V() instead? If so, why? While I am not sure
there is any practical difference between declaring V as a simple Variant or
as a Variant Array when it comes to the net result when assigning the result
of an Array function call to it, I would note that, according to the Help
files, the Array function returns "a Variant containing an array" and, as
such, does not need to have the variable it is being assigned to be a
variant array in order to work.
Rick
"Dave Peterson" wrote in message
...
Dim V as variant
declares V as a variant that will end up holding an array.
This is different than this:
Dim V() As Variant
Which declares V as an array that will hold different types of elements.
"Rick Rothstein (MVP - VB)" wrote:
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...
Dim V As Variant
V = Array(123, "Text String", Range("A1"))
MsgBox V(0) & vbCrLf & V(1) & vbCrLf & V(2).Address
Notice that the 3rd element, V(2), is a Range object, so to MessageBox
out
something from it, you need to reference one of its properties. True, I
could have let it use its default Value property, but I wanted to
positively
demonstrate that it was an actual object being stored in the third
element.
Rick
"Jeff" wrote in message
...
That works thanks for your help.
Is there a reason it has to be declared as a variant, I guess it really
doesnt matter for my case.
"Dave Peterson" wrote:
One way:
dim kk() as variant
dim iCtr as long
kk = array(1,2,3,4,5,6,7,8,9,0)
for ictr = lbound(kk) to ubound(kk)
msgbox kk(ictr) & "--" & ictr
next ictr
Jeff wrote:
Hi,
I wanted to assign constants to an array at once.
Dim KK(1 to 10) as double
KK = ( 1, 2, 3, 4, 5, 6, 7,8,9,0)
Doesnt work...
How can I assign values to the array at once without assigning one
by
one.
KK(1) = 1
KK(2) = 2
... etc
Thanks
--
Dave Peterson
--
Dave Peterson