LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Can you dimension an array in a way other than Variant?

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" wrote in message
...
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
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




 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
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[_2_] Excel Programming 3 November 13th 07 04:08 PM
Array problem: Key words-Variant Array, single-element, type mismatch error davidm Excel Programming 6 November 9th 05 05:54 AM
Array problem: Key words-Variant Array, single-element, type mismatch error davidm Excel Programming 1 November 8th 05 04:21 AM
Mutli-dimensional Array to Single-Dimension Array Blue Aardvark Excel Programming 3 October 15th 05 09:22 AM
Array transfer - 1 dimension v. 2 dimension JWolf[_2_] Excel Programming 2 June 29th 04 01:02 AM


All times are GMT +1. The time now is 05:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"