PC Review


Reply
Thread Tools Rate Thread

Can you dimension an array in a way other than Variant?

 
 
ExcelMonkey
Guest
Posts: n/a
 
      5th Jun 2008
I am loading text into a large array dimensioned as a Variant. Is this the
only way to dimension the Array? I am wondering if I can dimension the array
in a less memory intensive manor?

Thanks

EM
 
Reply With Quote
 
 
 
 
Per Jessen
Guest
Posts: n/a
 
      5th Jun 2008
On 5 Jun., 19:58, ExcelMonkey <ExcelMon...@discussions.microsoft.com>
wrote:
> I am loading text into a large array dimensioned as a Variant. *Is this the
> only way to dimension the Array? *I am wondering if I can dimension the array
> in a less memory intensive manor?
>
> Thanks
>
> EM


Hi

Yes you can use the same types as with other variables.

Dim MyArray(10) as String

Regards,
Per

 
Reply With Quote
 
Jim Thomlinson
Guest
Posts: n/a
 
      5th Jun 2008
While you are correct that you can declare your array as any data type you
want, your resulting array will use the same amount of memory as a variant.
The only difference is that the explicitly declared array will be more
efficient since the variable type will not need to be determined at run time.

In short whether it is an array of strings or a variant it is going to hold
the exact same data (an array of strings).
--
HTH...

Jim Thomlinson


"Per Jessen" wrote:

> On 5 Jun., 19:58, ExcelMonkey <ExcelMon...@discussions.microsoft.com>
> wrote:
> > I am loading text into a large array dimensioned as a Variant. Is this the
> > only way to dimension the Array? I am wondering if I can dimension the array
> > in a less memory intensive manor?
> >
> > Thanks
> >
> > EM

>
> Hi
>
> Yes you can use the same types as with other variables.
>
> Dim MyArray(10) as String
>
> Regards,
> Per
>
>

 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      5th Jun 2008
Hi Jim, not sure that's quite right

Sub foo()
Dim sArr(1 To 2) As String
Dim vArr(1 To 2) As Variant

Debug.Print VarPtr(sArr(2)) - VarPtr(sArr(1)) ' 4
Debug.Print VarPtr(vArr(2)) - VarPtr(vArr(1)) ' 16

End Sub

Regards,
Peter T


"Jim Thomlinson" <James_Thomlinson@owfg-Re-Move-This-.com> wrote in message
news:52090637-BB99-4B4D-925A-(E-Mail Removed)...
> While you are correct that you can declare your array as any data type you
> want, your resulting array will use the same amount of memory as a

variant.
> The only difference is that the explicitly declared array will be more
> efficient since the variable type will not need to be determined at run

time.
>
> In short whether it is an array of strings or a variant it is going to

hold
> the exact same data (an array of strings).
> --
> HTH...
>
> Jim Thomlinson
>
>
> "Per Jessen" wrote:
>
> > On 5 Jun., 19:58, ExcelMonkey <ExcelMon...@discussions.microsoft.com>
> > wrote:
> > > I am loading text into a large array dimensioned as a Variant. Is

this the
> > > only way to dimension the Array? I am wondering if I can dimension

the array
> > > in a less memory intensive manor?
> > >
> > > Thanks
> > >
> > > EM

> >
> > Hi
> >
> > Yes you can use the same types as with other variables.
> >
> > Dim MyArray(10) as String
> >
> > Regards,
> > Per
> >
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Array problem: Key words-Variant Array, single-element, type mismatch error davidm Microsoft Excel Programming 7 11th Jun 2011 12:01 AM
Combining Single Dimension to Multi Dimension Array Stathy K Microsoft Excel Programming 5 17th Feb 2009 06:18 PM
Redimming an array dynamically assigned from range (how to redim first dimension of a 2-D array? /or/ reverse the original array order) Keith R Microsoft Excel Programming 3 13th Nov 2007 04:08 PM
Fastest way to copy from a one dimension byte array to two dimension int array johannblake@yahoo.com Microsoft C# .NET 5 14th Jun 2005 07:45 PM
Array transfer - 1 dimension v. 2 dimension JWolf Microsoft Excel Programming 2 29th Jun 2004 01:02 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:25 AM.