LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default redimensioning arrays in subroutines

Les Gordon wrote:
I was wondering what would happen if you declared it as Variant then
redimensioned which would give it a definite array size; the later in the
code redimensioned again to a different array size. Would it behave since it
started life as a variant; or not behave since it now has a definite size and
so act like a declared array.

My appologies if you get two answers to this but the first response seems to
have disappeared in to the ether.

My response was in this thread yesterday, 3/31/08, at 6:26pm. Are you
not finding it? It was

It would be allowed.

Although I find it a bit offputting that after the first ReDim

e.g.,
Dim x
Redim x(10,10,10)

x in a sense refers both to the Variant variable and to the Variant()
array contained within the Variant variable, the Variant variable no
longer seems to be accessible. For example, Typename(x) will return
Variant() and IsArray(x) will return True, each obviously referring to
the array and not to the variable.

You might want to set up a simple experiment and see how things are
characterized in the Locals Window.

E.g.,

Sub testReDim()
Dim x(), y
ReDim x(10, 10, 10)
ReDim y(10, 10, 10)
x(1, 1, 1) = "xok"
y(1, 1, 1) = "yok"
ReDim Preserve x(10, 10, 1 To 11)
ReDim Preserve y(10, 10, 2 To 11)
Stop
End Sub

Alan Beban
 
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
turn off subroutines NDBC Excel Discussion (Misc queries) 3 July 27th 09 01:23 PM
Subscript out range error when redimensioning dynamic array Crazy Cat Excel Programming 1 January 12th 06 06:25 AM
Subroutines vs. modules BrianG[_4_] Excel Programming 0 September 7th 04 10:21 PM
common subroutines - add-in Tom Ogilvy Excel Programming 2 August 25th 04 12:51 AM
Run method for subroutines Scott Excel Programming 1 August 26th 03 04:46 PM


All times are GMT +1. The time now is 05:11 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"