"Array" and "Variant" is like saying
Is this apple Red or Peeled?

I think what you really want to know is if
Dim ABC 
declares a single value variable or array.

Because, without defining a type, the default
data type is Variant.  That means that:
Dim ABC
is the same as:
Dim ABC as Variant

and
Dim ABC(10)
is the same as
Dim ABC(10) as Variant
which is a 10 element array of type Variant values!

I think what is confusing you is that if you declare (Dim) a variable as one 
type, it's possible to Re-Declare (ReDim) the variable and change it to an 
array 
and even change type!

Dim Temp as Variant
redim Temp(10) as Integer

Now, let's say you have a string:
"Test One Two Three"
and you start out with an array:
dim Temp(2)

But that's not big enough to store the whole string, so you change the array 
size to 4:
ReDim Temp(4)
and:
Temp(0) = "Test"
Temp(1) = "One"
Temp(2) = "Two"
Temp(3) = "Three"

But that's a lot of work, because you first have to determine how many words 
are 
in the string, then re-define the size of the array to hold it.

The Split() function does all of that in one step:

Dim Temp
Temp = Split("Test One Two Three", " ")

It Redimensions the array based on the number of words, and stores the values.

Hope this helps,

paul




________________________________
From: hanumant shinde <hanumant_5...@yahoo.co.in>
To: excel macros <excel-macros@googlegroups.com>
Sent: Mon, February 14, 2011 3:12:43 PM
Subject: $$Excel-Macros$$ Re: Array or Variant ???


also pls tell me if dim abc is array then
does dim abc is equal to dim abc() ?





________________________________
From: hanumant shinde <hanumant_5...@yahoo.co.in>
To: excel macros <excel-macros@googlegroups.com>
Sent: Tue, 15 February, 2011 1:38:21 AM
Subject: Array or Variant ???


if i seclare variable like this 

dim abc

is this array or variant or something else. if array the what data type
i have code in my office (somebody else's code) where variables are declared 
like this and i thought these are variants but after going through paul's mail 
chain i guess those are arrays which seems more accurate. bcoz the kind of it 
has i always used to wonder how variant is used like an array.

so can somebody explain it.



-- 
----------------------------------------------------------------------------------

Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links : 
http://twitter.com/exceldailytip
2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com

To post to this group, send email to excel-macros@googlegroups.com
 
<><><><><><><><><><><><><><><><><><><><><><>
Like our page on facebook , Just follow below link
http://www.facebook.com/discussexcel

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links : 
http://twitter.com/exceldailytip
2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 
To post to this group, send email to excel-macros@googlegroups.com

<><><><><><><><><><><><><><><><><><><><><><>
Like our page on facebook , Just follow below link
http://www.facebook.com/discussexcel

Reply via email to